User Guide
© 2021 Is Daouda Games
2
Content
Getting started guide ........................................................................................................................................................................................................................................ 17
1. Introduction .............................................................................................................................................................................................................................................. 17
2. About the engine .................................................................................................................................................................................................................................... 17
3. Engine structure ..................................................................................................................................................................................................................................... 17
3.1 app_src .................................................................................................................................................................................................................................................. 17
3.2 isEngine ................................................................................................................................................................................................................................................ 18
3.3 assets...................................................................................................................................................................................................................................................... 18
3.4 main.cpp file ....................................................................................................................................................................................................................................... 18
3.4.1 main .................................................................................................................................................................................................................................................. 18
3.4.2 game.play ....................................................................................................................................................................................................................................... 18
3.4.3 game.basicSFMLmain .............................................................................................................................................................................................................. 18
Display ..................................................................................................................................................................................................................................................................... 18
1. class GameDisplay ................................................................................................................................................................................................................................. 18
2. Public methods ........................................................................................................................................................................................................................................ 19
2.1 GameDisplay ...................................................................................................................................................................................................................................... 19
2.2 step ......................................................................................................................................................................................................................................................... 19
2.3 draw ....................................................................................................................................................................................................................................................... 19
2.4 drawScreen ......................................................................................................................................................................................................................................... 19
2.5 showTempLoading.......................................................................................................................................................................................................................... 19
2.6 setOptionIndex .................................................................................................................................................................................................................................. 19
2.7 setTextAnimation ............................................................................................................................................................................................................................ 20
2.8 setView.................................................................................................................................................................................................................................................. 20
2.9 setViewVarX ....................................................................................................................................................................................................................................... 20
2.10 setViewVarY ................................................................................................................................................................................................................................. 20
2.11 setViewVarXY .............................................................................................................................................................................................................................. 20
2.12 setViewSize ................................................................................................................................................................................................................................... 21
2.13 setWindowSize ........................................................................................................................................................................................................................... 21
2.14 setWindowTitle .......................................................................................................................................................................................................................... 21
2.15 setWindowBgColor ................................................................................................................................................................................................................... 21
2.16 loadParentResources ............................................................................................................................................................................................................... 21
2.17 loadResources ............................................................................................................................................................................................................................. 21
2.18 setIsRunning ................................................................................................................................................................................................................................ 21
2.19 setIsPlaying................................................................................................................................................................................................................................... 21
2.20 quitScene ....................................................................................................................................................................................................................................... 22
2.21 setSceneStart ............................................................................................................................................................................................................................... 22
2.22 setSceneEnd ................................................................................................................................................................................................................................. 22
2.23 setKeyBackPressed ................................................................................................................................................................................................................... 22
2.24 getIsRunning ................................................................................................................................................................................................................................ 22
2.25 getIsPlaying .................................................................................................................................................................................................................................. 22
2.26 getSceneStart ............................................................................................................................................................................................................................... 22
2.27 getSceneEnd ................................................................................................................................................................................................................................. 22
2.28 getWindowIsActive ................................................................................................................................................................................................................... 23
2.29 getKeyBackPressed................................................................................................................................................................................................................... 23
3
2.30 getView ........................................................................................................................................................................................................................................... 23
2.31 getRenderWindow .................................................................................................................................................................................................................... 23
2.32 getRenderTexture ..................................................................................................................................................................................................................... 23
2.33 getGameSystem .......................................................................................................................................................................................................................... 23
2.34 getFontSystem............................................................................................................................................................................................................................. 23
2.35 getFontMsg ................................................................................................................................................................................................................................... 23
2.36 getSprButtonSelect ................................................................................................................................................................................................................... 24
2.37 getOptionIndex ........................................................................................................................................................................................................................... 24
2.38 getSceneWidth ............................................................................................................................................................................................................................ 24
2.39 getSceneHeight ........................................................................................................................................................................................................................... 24
2.40 getDeltaTime ................................................................................................................................................................................................................................ 24
2.41 getDELTA_TIME ......................................................................................................................................................................................................................... 24
2.42 getSprButtonSelectScale ........................................................................................................................................................................................................ 24
2.43 getViewX ........................................................................................................................................................................................................................................ 24
2.44 getViewY ........................................................................................................................................................................................................................................ 25
2.45 getViewW ...................................................................................................................................................................................................................................... 25
2.46 getViewH ........................................................................................................................................................................................................................................ 25
2.47 getBgColor ..................................................................................................................................................................................................................................... 25
2.48 inViewRec ...................................................................................................................................................................................................................................... 25
2.49 mouseCollision ............................................................................................................................................................................................................................ 25
2.50 SDMmanageScene ..................................................................................................................................................................................................................... 26
2.51 SDMmanageSceneEvents ....................................................................................................................................................................................................... 27
2.52 SDMmanageSceneMsgAnswers .......................................................................................................................................................................................... 27
2.53 SDMcallObjectsEvents ............................................................................................................................................................................................................. 27
2.54 SDMstep ......................................................................................................................................................................................................................................... 27
2.55 SDMdraw ....................................................................................................................................................................................................................................... 27
2.56 GSMplaySound ............................................................................................................................................................................................................................ 27
2.57 GSMpauseSound ......................................................................................................................................................................................................................... 27
2.58 GSMpauseSound ......................................................................................................................................................................................................................... 27
Allows to stop sound managed by GSM. .................................................................................................................................................................................................. 28
2.59 GSMplayMusic ............................................................................................................................................................................................................................. 28
2.60 GSMpauseMusic .......................................................................................................................................................................................................................... 28
2.61 GSMstopMusic ............................................................................................................................................................................................................................. 28
Allows to stop music managed by GSM. .................................................................................................................................................................................................. 28
2.62 controlEventFocusClosing ..................................................................................................................................................................................................... 28
3. Protected elements ............................................................................................................................................................................................................................... 28
3.1 enum MsgAnswer ............................................................................................................................................................................................................................ 28
3.2 showMessageBox ............................................................................................................................................................................................................................. 28
3.3 updateMsgBox ................................................................................................................................................................................................................................... 29
3.4 updateTimeWait............................................................................................................................................................................................................................... 29
3.5 drawMsgBox....................................................................................................................................................................................................................................... 29
SDM (Step and Draw Manager) ................................................................................................................................................................................................................... 29
1. class SDM ................................................................................................................................................................................................................................................... 29
4
2. Publics elements of SDM .................................................................................................................................................................................................................... 29
2.1 m_SDMsceneObjects ....................................................................................................................................................................................................................... 29
2.2 SDMgetObject .................................................................................................................................................................................................................................... 30
2.3 SDMaddSceneObject ....................................................................................................................................................................................................................... 30
2.4 SDMaddSprite .................................................................................................................................................................................................................................... 30
2.5 SDMsetObjDepth .............................................................................................................................................................................................................................. 30
Game Sound .......................................................................................................................................................................................................................................................... 30
1. class GameSound .................................................................................................................................................................................................................................... 30
2. Publics elements of GameSound ..................................................................................................................................................................................................... 31
2.1 GameSound ......................................................................................................................................................................................................................................... 31
2.2 loadResources ................................................................................................................................................................................................................................... 31
2.3 getSoundBuffer ................................................................................................................................................................................................................................. 31
2.4 getSound .............................................................................................................................................................................................................................................. 31
Game Music ........................................................................................................................................................................................................................................................... 31
1. class GameMusic ..................................................................................................................................................................................................................................... 31
2. Publics elements of GameMusic ...................................................................................................................................................................................................... 31
2.1 GameMusic .......................................................................................................................................................................................................................................... 31
2.2 loadResources ................................................................................................................................................................................................................................... 32
2.3 getMusic ............................................................................................................................................................................................................................................... 32
GSM (Game Sound Manager) ........................................................................................................................................................................................................................ 32
1. class GSM .................................................................................................................................................................................................................................................... 32
2. Publics elements of GSM ..................................................................................................................................................................................................................... 32
2.1 GSM Containers ................................................................................................................................................................................................................................. 32
2.2 GSMaddSound ................................................................................................................................................................................................................................... 32
2.3 GSMaddMusic .................................................................................................................................................................................................................................... 32
2.4 GSMgetSound ..................................................................................................................................................................................................................................... 33
2.5 GSMgetMusic ...................................................................................................................................................................................................................................... 33
Game Texture ....................................................................................................................................................................................................................................................... 33
1. class GameTexture ................................................................................................................................................................................................................................ 33
2. Publics elements of GameTexture ................................................................................................................................................................................................. 33
2.1 GameTexture ...................................................................................................................................................................................................................................... 33
2.2 loadResources ................................................................................................................................................................................................................................... 33
2.3 getTexture ........................................................................................................................................................................................................................................... 33
Game Font .............................................................................................................................................................................................................................................................. 34
1. class GameFont ....................................................................................................................................................................................................................................... 34
2. Publics elements of GameFont ........................................................................................................................................................................................................ 34
2.1 GameFont ............................................................................................................................................................................................................................................. 34
2.2 loadResources ................................................................................................................................................................................................................................... 34
2.3 getFont .................................................................................................................................................................................................................................................. 34
GRM (Graphic Resource Manager) ............................................................................................................................................................................................................ 34
1. class GRM ................................................................................................................................................................................................................................................... 34
2. Publics element of GRM ...................................................................................................................................................................................................................... 35
2.1 GRM Containers ................................................................................................................................................................................................................................ 35
5
2.2 GRMaddFont ...................................................................................................................................................................................................................................... 35
2.3 GRMaddTexture................................................................................................................................................................................................................................ 35
2.4 GSMgetFont ........................................................................................................................................................................................................................................ 35
2.5 GSMgetTexture.................................................................................................................................................................................................................................. 35
Transition Effect ................................................................................................................................................................................................................................................. 36
1. class Transition Effect .......................................................................................................................................................................................................................... 36
2. Publics element of Transition Effect ............................................................................................................................................................................................. 36
2.1 Enum Transition............................................................................................................................................................................................................................... 36
2.2 TransitionEffect ................................................................................................................................................................................................................................ 36
2.3 step ......................................................................................................................................................................................................................................................... 36
2.4 draw ....................................................................................................................................................................................................................................................... 36
2.5 setType.................................................................................................................................................................................................................................................. 36
2.6 getTransitionEnd ............................................................................................................................................................................................................................. 36
Entities .................................................................................................................................................................................................................................................................... 37
1. class MainObject ..................................................................................................................................................................................................................................... 37
2. Publics elements of MainObjet ........................................................................................................................................................................................................ 37
2.1 MainObject .......................................................................................................................................................................................................................................... 37
2.2 instanceNumber ............................................................................................................................................................................................................................... 37
2.3 m_SDMcallStep .................................................................................................................................................................................................................................. 38
2.4 m_SDMcallDraw ................................................................................................................................................................................................................................ 38
2.5 m_SDMcallEvent ............................................................................................................................................................................................................................... 38
2.6 step ......................................................................................................................................................................................................................................................... 38
2.7 event ....................................................................................................................................................................................................................................................... 38
2.8 setXStart ............................................................................................................................................................................................................................................... 38
2.9 setYStart ............................................................................................................................................................................................................................................... 38
2.10 setXPrevious ................................................................................................................................................................................................................................ 38
2.11 setYPrevious ................................................................................................................................................................................................................................ 39
2.12 setStartPosition .......................................................................................................................................................................................................................... 39
2.13 setX ................................................................................................................................................................................................................................................... 39
2.14 setY ................................................................................................................................................................................................................................................... 39
2.15 moveX .............................................................................................................................................................................................................................................. 39
2.16 moveY .............................................................................................................................................................................................................................................. 39
2.17 setPosition..................................................................................................................................................................................................................................... 39
2.18 setSpriteScale .............................................................................................................................................................................................................................. 39
2.19 setSpeed ......................................................................................................................................................................................................................................... 40
2.20 setHsp .............................................................................................................................................................................................................................................. 40
2.21 setVsp .............................................................................................................................................................................................................................................. 40
2.22 setAngularMove ......................................................................................................................................................................................................................... 40
2.23 setFrame ........................................................................................................................................................................................................................................ 40
2.24 setImageXscale............................................................................................................................................................................................................................ 40
2.25 setImageYscale............................................................................................................................................................................................................................ 40
2.26 setImageScale .............................................................................................................................................................................................................................. 40
2.27 setImageScaleX_Y....................................................................................................................................................................................................................... 41
6
Set the x and y scale of the object. .............................................................................................................................................................................................................. 41
2.28 setImageAngle ............................................................................................................................................................................................................................. 41
2.29 setXOffset ....................................................................................................................................................................................................................................... 41
2.30 setYOffset ....................................................................................................................................................................................................................................... 41
2.31 setXYOffset .................................................................................................................................................................................................................................... 41
2.32 setXYOffset .................................................................................................................................................................................................................................... 41
2.33 setTime ........................................................................................................................................................................................................................................... 41
2.34 setImageAlpha............................................................................................................................................................................................................................. 41
2.35 setImageIndex ............................................................................................................................................................................................................................. 42
2.36 setMaskW ...................................................................................................................................................................................................................................... 42
2.37 setMaskH ....................................................................................................................................................................................................................................... 42
2.38 setRectangleMask ...................................................................................................................................................................................................................... 42
2.39 setCircleMask............................................................................................................................................................................................................................... 42
2.40 setIsActive ..................................................................................................................................................................................................................................... 42
2.41 updateCollisionMask ................................................................................................................................................................................................................ 42
2.42 centerCollisionMask ................................................................................................................................................................................................................. 43
2.43 updateSprite ................................................................................................................................................................................................................................. 43
2.44 draw ................................................................................................................................................................................................................................................. 43
2.45 drawMask ...................................................................................................................................................................................................................................... 43
2.46 getMask........................................................................................................................................................................................................................................... 43
2.47 getCircleMask .............................................................................................................................................................................................................................. 43
2.48 getX ................................................................................................................................................................................................................................................... 44
2.49 getY ................................................................................................................................................................................................................................................... 44
2.50 getXStart ......................................................................................................................................................................................................................................... 44
2.51 getYStart ......................................................................................................................................................................................................................................... 44
2.52 getXPrevious ................................................................................................................................................................................................................................ 44
2.53 getYPrevious ................................................................................................................................................................................................................................ 44
2.54 distantToPoint ............................................................................................................................................................................................................................ 44
2.55 distantToObject .......................................................................................................................................................................................................................... 44
2.56 pointDirection ............................................................................................................................................................................................................................. 45
2.57 pointDirectionSprite ................................................................................................................................................................................................................ 45
2.58 getSpeed ......................................................................................................................................................................................................................................... 45
2.59 getHsp ............................................................................................................................................................................................................................................. 45
2.60 getVsp .............................................................................................................................................................................................................................................. 45
2.61 getFrame ........................................................................................................................................................................................................................................ 45
2.62 getFrameStart .............................................................................................................................................................................................................................. 46
2.63 getFrameEnd................................................................................................................................................................................................................................ 46
2.64 getImageXscale ........................................................................................................................................................................................................................... 46
2.65 getImageYscale ........................................................................................................................................................................................................................... 46
2.66 getImageScale .............................................................................................................................................................................................................................. 46
2.67 getImageAngle ............................................................................................................................................................................................................................ 46
2.68 getXOffset ...................................................................................................................................................................................................................................... 46
2.69 getYOffset ...................................................................................................................................................................................................................................... 46
7
2.70 getTime ........................................................................................................................................................................................................................................... 47
2.71 getInstanceId ............................................................................................................................................................................................................................... 47
2.72 getMaskW ...................................................................................................................................................................................................................................... 47
2.73 getMaskH ....................................................................................................................................................................................................................................... 47
2.74 getIsActive ..................................................................................................................................................................................................................................... 47
2.75 getImageAlpha ............................................................................................................................................................................................................................ 47
2.76 getImageIndex ............................................................................................................................................................................................................................. 47
2.77 getSpriteWidth ............................................................................................................................................................................................................................ 47
2.78 getSpriteHeight ........................................................................................................................................................................................................................... 48
2.79 getSpriteX ...................................................................................................................................................................................................................................... 48
2.80 getSpriteY ...................................................................................................................................................................................................................................... 48
2.81 getTextureWidth ........................................................................................................................................................................................................................ 48
2.82 getTextureHeight ....................................................................................................................................................................................................................... 48
2.83 getSpriteCenterX ........................................................................................................................................................................................................................ 48
2.84 getSpriteCenterY ........................................................................................................................................................................................................................ 48
2.85 getSpriteNumberSubImage .................................................................................................................................................................................................. 48
2.86 placeMetting ................................................................................................................................................................................................................................. 49
2.87 inViewRec ...................................................................................................................................................................................................................................... 49
2.88 getSprite ......................................................................................................................................................................................................................................... 49
2.89 setFrameLimit ............................................................................................................................................................................................................................. 49
3. Other functions of MainObject ......................................................................................................................................................................................................... 49
3.1 instanceExist ...................................................................................................................................................................................................................................... 49
3.2 operator() ............................................................................................................................................................................................................................................ 50
3.3 sortObjArrayByX .............................................................................................................................................................................................................................. 50
3.4 sortObjArrayByDepth .................................................................................................................................................................................................................... 50
3.5 operator< ............................................................................................................................................................................................................................................. 50
Forms for collision masks .............................................................................................................................................................................................................................. 51
1. class Rectangle ........................................................................................................................................................................................................................................ 51
2. class Circle ................................................................................................................................................................................................................................................. 51
The Parent Classes of MainObject .............................................................................................................................................................................................................. 51
1. class DepthObject ................................................................................................................................................................................................................................... 51
1.1 enum Depth ........................................................................................................................................................................................................................................ 51
1.2 DepthObject ........................................................................................................................................................................................................................................ 52
1.3 setDepth ............................................................................................................................................................................................................................................... 52
1.4 getDepth ............................................................................................................................................................................................................................................... 52
2. class Destructible ................................................................................................................................................................................................................................... 52
2.1 Destructible ........................................................................................................................................................................................................................................ 52
2.2 setDestroyed ...................................................................................................................................................................................................................................... 52
2.3 isDestroyed ......................................................................................................................................................................................................................................... 52
3. class Visibility .......................................................................................................................................................................................................................................... 53
3.1 Visibility................................................................................................................................................................................................................................................ 53
3.2 setVisible .............................................................................................................................................................................................................................................. 53
3.3 getVisible ............................................................................................................................................................................................................................................. 53
8
4. class Health ............................................................................................................................................................................................................................................... 53
4.1 Health .................................................................................................................................................................................................................................................... 53
4.2 setHealth .............................................................................................................................................................................................................................................. 54
4.3 setMaxHealth ..................................................................................................................................................................................................................................... 54
4.4 addHealth ............................................................................................................................................................................................................................................ 54
4.5 getHealth .............................................................................................................................................................................................................................................. 54
4.6 getMaxHealth ..................................................................................................................................................................................................................................... 54
5. class HurtEffect ....................................................................................................................................................................................................................................... 54
5.1 HurtEffect ............................................................................................................................................................................................................................................ 54
5.2 hurtStep ................................................................................................................................................................................................................................................ 55
5.3 setIsHurt............................................................................................................................................................................................................................................... 55
5.4 getIsHurt .............................................................................................................................................................................................................................................. 55
6. class ScorePoint ...................................................................................................................................................................................................................................... 55
6.1 ScorePoint ........................................................................................................................................................................................................................................... 55
6.2 setScorePoint ..................................................................................................................................................................................................................................... 55
6.3 getScorePoint ..................................................................................................................................................................................................................................... 55
7. class Step .................................................................................................................................................................................................................................................... 55
7.1 Step ......................................................................................................................................................................................................................................................... 56
7.2 setStep ................................................................................................................................................................................................................................................... 56
7.3 addStep ................................................................................................................................................................................................................................................. 56
7.4 reduceStep .......................................................................................................................................................................................................................................... 56
7.5 getStep................................................................................................................................................................................................................................................... 56
8. class Name ................................................................................................................................................................................................................................................. 56
8.1 Name ...................................................................................................................................................................................................................................................... 56
8.2 setName ................................................................................................................................................................................................................................................ 56
8.3 getName ............................................................................................................................................................................................................................................... 57
9. class FilePath ............................................................................................................................................................................................................................................ 57
9.1 FilePath ................................................................................................................................................................................................................................................. 57
9.2 setFilePath ........................................................................................................................................................................................................................................... 57
9.3 getFilePath .......................................................................................................................................................................................................................................... 57
9.4 getFileIsLoaded................................................................................................................................................................................................................................. 57
10. class Type ............................................................................................................................................................................................................................................ 57
10.1 Type .................................................................................................................................................................................................................................................. 57
10.2 setType ........................................................................................................................................................................................................................................... 58
10.3 getType ........................................................................................................................................................................................................................................... 58
The Backgroud..................................................................................................................................................................................................................................................... 58
1. class Background ................................................................................................................................................................................................................................... 58
2. Public methods ........................................................................................................................................................................................................................................ 58
2.1 Background ......................................................................................................................................................................................................................................... 58
2.2 step ......................................................................................................................................................................................................................................................... 58
Button ...................................................................................................................................................................................................................................................................... 58
1. class Button ............................................................................................................................................................................................................................................... 59
2. Public methods ........................................................................................................................................................................................................................................ 59
9
2.1 Button .................................................................................................................................................................................................................................................... 59
2.2 setTitle .................................................................................................................................................................................................................................................. 59
2.3 onClick ................................................................................................................................................................................................................................................... 59
2.4 onMouseOver ..................................................................................................................................................................................................................................... 59
2.5 event ....................................................................................................................................................................................................................................................... 59
2.6 step ......................................................................................................................................................................................................................................................... 60
2.7 draw ....................................................................................................................................................................................................................................................... 60
2.8 getText .................................................................................................................................................................................................................................................. 60
2.9 getIsInCollision ................................................................................................................................................................................................................................. 60
Admob ..................................................................................................................................................................................................................................................................... 60
1. class AdmobManager ........................................................................................................................................................................................................................... 60
2. Public methods ........................................................................................................................................................................................................................................ 60
2.1 AdmobManager ................................................................................................................................................................................................................................ 60
2.2 loadBannerAd .................................................................................................................................................................................................................................... 60
2.3 showBannerAd .................................................................................................................................................................................................................................. 61
2.4 hideBannerAd .................................................................................................................................................................................................................................... 61
2.5 loadRewardVideo ............................................................................................................................................................................................................................ 61
2.6 showRewardVideo .......................................................................................................................................................................................................................... 61
2.7 updateSFMLApp ............................................................................................................................................................................................................................... 61
2.8 checkAdObjInit .................................................................................................................................................................................................................................. 61
2.9 checkAdRewardObjReinitialize ................................................................................................................................................................................................ 61
3. Other Functions of AdmobManager .............................................................................................................................................................................................. 61
3.1 ProcessEvents & WaitForFutureCompletion ..................................................................................................................................................................... 61
3.2 checkAdState ...................................................................................................................................................................................................................................... 62
Time .......................................................................................................................................................................................................................................................................... 62
1. class GameTime ...................................................................................................................................................................................................................................... 62
2. Public methods of GameTime .......................................................................................................................................................................................................... 62
2.1 GameTime ........................................................................................................................................................................................................................................... 62
2.2 step ......................................................................................................................................................................................................................................................... 62
2.3 addTimeValue .................................................................................................................................................................................................................................... 63
2.4 setTimeValue ..................................................................................................................................................................................................................................... 63
2.5 setMSecond ......................................................................................................................................................................................................................................... 63
2.6 getTimeString .................................................................................................................................................................................................................................... 63
2.7 getTimeValue ..................................................................................................................................................................................................................................... 63
2.8 getMinute ............................................................................................................................................................................................................................................. 63
2.9 getSecond ............................................................................................................................................................................................................................................. 63
2.10 getMSecond .................................................................................................................................................................................................................................. 63
2.11 compareTime ............................................................................................................................................................................................................................... 64
2.12 operator= ....................................................................................................................................................................................................................................... 64
2.13 operator<< .................................................................................................................................................................................................................................... 64
3. Other functions of GameTime .......................................................................................................................................................................................................... 64
Game control ........................................................................................................................................................................................................................................................ 64
1. Elements of GameKeyData ................................................................................................................................................................................................................ 64
10
2.1 enum VirtualKeyIndex .................................................................................................................................................................................................................. 64
2.2 GameKeyData .................................................................................................................................................................................................................................... 65
2.3 loadResources ................................................................................................................................................................................................................................... 65
2.4 step ......................................................................................................................................................................................................................................................... 65
2.5 draw ....................................................................................................................................................................................................................................................... 65
2.6 m_keyPausePressed ....................................................................................................................................................................................................................... 65
2.7 m_keyLeftPressed ............................................................................................................................................................................................................................ 65
2.8 m_keyRightPressed ......................................................................................................................................................................................................................... 65
2.9 m_keyUpPressed .............................................................................................................................................................................................................................. 66
2.10 m_keyDownPressed ................................................................................................................................................................................................................. 66
2.11 m_keyAPressed ........................................................................................................................................................................................................................... 66
2.12 m_keyBPressed ........................................................................................................................................................................................................................... 66
2.13 m_keyAUsed ................................................................................................................................................................................................................................. 66
2.14 m_keyBUsed ................................................................................................................................................................................................................................. 66
2.15 m_keyLeftUsed ............................................................................................................................................................................................................................ 66
2.16 m_keyRightUsed ......................................................................................................................................................................................................................... 66
2.17 m_keyUpUsed .............................................................................................................................................................................................................................. 67
2.18 m_keyDownUsed ........................................................................................................................................................................................................................ 67
2.19 m_disableAllKey ......................................................................................................................................................................................................................... 67
2.20 m_hideGamePad ......................................................................................................................................................................................................................... 67
2.21 m_keyboardA ............................................................................................................................................................................................................................... 67
2.22 m_keyboardB ............................................................................................................................................................................................................................... 67
2.23 m_keyboardLeft .......................................................................................................................................................................................................................... 67
2.24 m_keyboardRight ....................................................................................................................................................................................................................... 67
2.25 m_keyboardUp ............................................................................................................................................................................................................................ 68
2.26 m_keyboardDown...................................................................................................................................................................................................................... 68
2.27 m_moveKeyPressed .................................................................................................................................................................................................................. 68
2.28 m_actionKeyPressed ................................................................................................................................................................................................................ 68
2.29 keyLeftPressed ............................................................................................................................................................................................................................ 68
2.30 keyRightPressed......................................................................................................................................................................................................................... 68
2.31 keyUpPressed .............................................................................................................................................................................................................................. 68
2.32 keyDownPressed ....................................................................................................................................................................................................................... 68
2.33 keyAPressed ................................................................................................................................................................................................................................. 69
2.34 keyBPressed ................................................................................................................................................................................................................................. 69
2.35 virtualKeyPressed ..................................................................................................................................................................................................................... 69
2. Other functions of GameKeyData ................................................................................................................................................................................................... 69
Game Slider ........................................................................................................................................................................................................................................................... 69
1. class Game Slider.................................................................................................................................................................................................................................... 69
2. Publics elements of Game Slider ..................................................................................................................................................................................................... 70
2.1 Slider Direction ................................................................................................................................................................................................................................. 70
2.2 GameSlider .......................................................................................................................................................................................................................................... 70
2.3 step ......................................................................................................................................................................................................................................................... 70
2.4 getSliderDirection ........................................................................................................................................................................................................................... 70
11
Game System ........................................................................................................................................................................................................................................................ 70
1. class GameSystem .................................................................................................................................................................................................................................. 70
2. Elements of GameSystem ................................................................................................................................................................................................................... 70
2.1 enum ValidationButton ................................................................................................................................................................................................................. 70
2.2 GameSystem ....................................................................................................................................................................................................................................... 71
2.3 isPressed .............................................................................................................................................................................................................................................. 71
2.4 keyIsPressed ...................................................................................................................................................................................................................................... 72
2.5 fileExist ................................................................................................................................................................................................................................................. 72
2.6 playSound ............................................................................................................................................................................................................................................ 72
2.7 playMusic ............................................................................................................................................................................................................................................. 72
2.8 stopSound ............................................................................................................................................................................................................................................ 72
2.9 stopMusic ............................................................................................................................................................................................................................................. 72
2.10 useVibrate ..................................................................................................................................................................................................................................... 73
2.11 saveConfig ..................................................................................................................................................................................................................................... 73
2.12 loadConfig...................................................................................................................................................................................................................................... 73
2.13 savePadConfig ............................................................................................................................................................................................................................. 73
2.14 loadPadConfig ............................................................................................................................................................................................................................. 73
2.15 m_disableKey ............................................................................................................................................................................................................................... 73
2.16 m_enableSound ........................................................................................................................................................................................................................... 73
2.17 m_enableMusic ............................................................................................................................................................................................................................ 73
2.18 m_enableVibrate ........................................................................................................................................................................................................................ 74
2.19 m_keyIsPressed .......................................................................................................................................................................................................................... 74
2.20 m_firstLaunch .............................................................................................................................................................................................................................. 74
2.21 m_validationMouseKey ........................................................................................................................................................................................................... 74
2.22 m_validationKeyboardKey .................................................................................................................................................................................................... 74
2.23 m_gameLanguage ...................................................................................................................................................................................................................... 74
2.24 m_padAlpha .................................................................................................................................................................................................................................. 74
Game System Extended ................................................................................................................................................................................................................................... 75
1. class GameSystemExtended.............................................................................................................................................................................................................. 75
2. Elements of GameSystemExtended ............................................................................................................................................................................................... 75
2.1 GameSystemExtended ................................................................................................................................................................................................................... 75
2.2 initSystemData .................................................................................................................................................................................................................................. 75
2.3 initProgress ........................................................................................................................................................................................................................................ 75
2.4 initData ................................................................................................................................................................................................................................................. 75
2.5 saveData ............................................................................................................................................................................................................................................... 75
2.6 loadData ............................................................................................................................................................................................................................................... 75
2.7 m_launchOption ................................................................................................................................................................................................................................ 76
2.8 game play variables ........................................................................................................................................................................................................................ 76
Game Function ..................................................................................................................................................................................................................................................... 76
1. General Function .................................................................................................................................................................................................................................... 76
1.1 VALUE_CONVERSION .................................................................................................................................................................................................................... 76
1.2 SECOND ................................................................................................................................................................................................................................................ 76
1.3 WITH ...................................................................................................................................................................................................................................................... 76
12
1.4 closeApplication ............................................................................................................................................................................................................................... 77
Allows to close the application. ................................................................................................................................................................................................................... 77
1.5 w_chart_tToStr .................................................................................................................................................................................................................................. 77
1.6 strToWStr ............................................................................................................................................................................................................................................ 77
1.7 numToStr ............................................................................................................................................................................................................................................. 77
1.8 strToNum ............................................................................................................................................................................................................................................. 77
1.9 numToWStr ........................................................................................................................................................................................................................................ 77
1.10 writeZero ....................................................................................................................................................................................................................................... 78
1.11 getMSecond .................................................................................................................................................................................................................................. 78
1.12 makeTime ...................................................................................................................................................................................................................................... 78
1.13 showLog ......................................................................................................................................................................................................................................... 78
1.14 arraySize ........................................................................................................................................................................................................................................ 78
1.15 choose.............................................................................................................................................................................................................................................. 78
1.16 random............................................................................................................................................................................................................................................ 79
1.17 setVarLimit ................................................................................................................................................................................................................................... 79
1.18 isIn .................................................................................................................................................................................................................................................... 79
1.19 isBetween ...................................................................................................................................................................................................................................... 79
1.20 isCrossing ...................................................................................................................................................................................................................................... 79
1.21 side .................................................................................................................................................................................................................................................... 79
1.22 sign .................................................................................................................................................................................................................................................... 80
1.23 pointDirection ............................................................................................................................................................................................................................. 80
1.24 pointDistance ............................................................................................................................................................................................................................... 80
1.25 radToDeg ....................................................................................................................................................................................................................................... 80
1.26 degToRad ....................................................................................................................................................................................................................................... 80
1.27 lengthDirX ..................................................................................................................................................................................................................................... 80
1.28 lengthDirY ..................................................................................................................................................................................................................................... 80
1.29 increaseVar ................................................................................................................................................................................................................................... 81
1.30 decreaseVar .................................................................................................................................................................................................................................. 81
1.31 collisionTest ................................................................................................................................................................................................................................. 81
2. Function on objects SFML .................................................................................................................................................................................................................. 81
2.1 setVector2 ........................................................................................................................................................................................................................................... 81
2.2 getSFMLObjAngle ............................................................................................................................................................................................................................ 81
2.3 getSFMLObjXScale ........................................................................................................................................................................................................................... 82
2.4 getSFMLObjYScale ........................................................................................................................................................................................................................... 82
2.5 getSFMLObjWidth ........................................................................................................................................................................................................................... 82
2.6 getSFMLObjHeight .......................................................................................................................................................................................................................... 82
2.7 getSFMLTextureWidth .................................................................................................................................................................................................................. 82
2.8 getSFMLTextureHeight ................................................................................................................................................................................................................. 82
2.9 getSFMLObjOriginX ........................................................................................................................................................................................................................ 82
2.10 getSFMLObjOriginY .................................................................................................................................................................................................................. 83
2.11 getSFMLObjX ................................................................................................................................................................................................................................ 83
2.12 getSFMLObjY ................................................................................................................................................................................................................................ 83
2.13 setSFMLObjAngle ....................................................................................................................................................................................................................... 83
13
2.14 setSFMLObjRotate ..................................................................................................................................................................................................................... 83
2.15 setSFMLObjScaleX_Y ................................................................................................................................................................................................................ 84
2.16 setSFMLObjScale ........................................................................................................................................................................................................................ 84
2.17 setSFMLObjOrigin ..................................................................................................................................................................................................................... 84
2.18 setSFMLObjX ................................................................................................................................................................................................................................ 84
2.19 setSFMLObjY ................................................................................................................................................................................................................................ 84
2.20 centerSFMLObj............................................................................................................................................................................................................................ 84
2.21 centerSFMLObjX ......................................................................................................................................................................................................................... 85
2.22 centerSFMLObjY ......................................................................................................................................................................................................................... 85
2.23 setSFMLObjX_Y ........................................................................................................................................................................................................................... 85
2.24 moveSFMLObjX........................................................................................................................................................................................................................... 85
2.25 moveSFMLObjY........................................................................................................................................................................................................................... 85
2.26 setSFMLObjSize .......................................................................................................................................................................................................................... 85
2.27 setSFMLObjAlpha ...................................................................................................................................................................................................................... 86
2.28 setSFMLObjAlpha2 .................................................................................................................................................................................................................... 86
2.29 setSFMLObjColor ....................................................................................................................................................................................................................... 86
2.30 setSFMLObjFillColor................................................................................................................................................................................................................. 86
2.31 scaleAnimation ........................................................................................................................................................................................................................... 87
2.32 setFrame ........................................................................................................................................................................................................................................ 87
2.33 setSFMLObjOutlineColor ........................................................................................................................................................................................................ 87
2.34 setSFMLObjTexRec ................................................................................................................................................................................................................... 87
2.35 setSFMLObjProperties ............................................................................................................................................................................................................ 87
2.36 loadSFMLTexture ...................................................................................................................................................................................................................... 88
2.37 loadSFMLFont ............................................................................................................................................................................................................................. 88
2.38 loadSFMLSoundBuffer ............................................................................................................................................................................................................ 88
2.39 loadSFMLMusic ........................................................................................................................................................................................................................... 88
2.40 checkSFMLSndState ................................................................................................................................................................................................................. 88
2.41 playSFMLsnd ................................................................................................................................................................................................................................ 89
2.42 stopSFMLsnd ............................................................................................................................................................................................................................... 89
2.43 pauseSFMLsnd ............................................................................................................................................................................................................................ 89
2.44 loopSFMLsnd ............................................................................................................................................................................................................................... 89
2.45 collisionTestSFML ..................................................................................................................................................................................................................... 89
2.46 createRectangle .......................................................................................................................................................................................................................... 89
2.47 textStyleConfig ............................................................................................................................................................................................................................ 90
2.48 createWText ................................................................................................................................................................................................................................. 90
2.49 createText ...................................................................................................................................................................................................................................... 90
2.50 createSprite .................................................................................................................................................................................................................................. 90
2.51 getCursor ....................................................................................................................................................................................................................................... 91
2.52 mouseCollision ............................................................................................................................................................................................................................ 91
3. Other functions ....................................................................................................................................................................................................................................... 92
3.1 clear ........................................................................................................................................................................................................................................................ 92
3.2 draw ....................................................................................................................................................................................................................................................... 92
3.3 display ................................................................................................................................................................................................................................................... 92
14
3.4 setFPS .................................................................................................................................................................................................................................................... 93
3.5 vibrate ................................................................................................................................................................................................................................................... 93
3.6 openURL ............................................................................................................................................................................................................................................... 93
3.7 jstring2string ..................................................................................................................................................................................................................................... 93
3.8 getDeviceId ......................................................................................................................................................................................................................................... 93
External library ................................................................................................................................................................................................................................................... 93
1. Tiny File Dialogs (only for Windows and Linux) .................................................................................................................................................................... 93
2.1 class TinyDialogBox ........................................................................................................................................................................................................................ 93
2.2 tinyString ............................................................................................................................................................................................................................................. 94
2.3 TINY_FILE_DIALOGBOX_PATH .................................................................................................................................................................................................. 94
2.4 enum FileDialogType ..................................................................................................................................................................................................................... 94
2.5 enum DialogType ............................................................................................................................................................................................................................. 94
2.6 enum IconType ................................................................................................................................................................................................................................. 94
2.7 enumDialogTypeToStr / enumIconTypeToStr .................................................................................................................................................................. 95
2.8 showDialogBox ................................................................................................................................................................................................................................. 95
2.9 showFileDialogBox ......................................................................................................................................................................................................................... 95
2.10 showFolderDialogBox ............................................................................................................................................................................................................. 95
2. Box 2D ......................................................................................................................................................................................................................................................... 96
3. TMXLite....................................................................................................................................................................................................................................................... 96
Game Engine ......................................................................................................................................................................................................................................................... 96
1. class GameEngine .................................................................................................................................................................................................................................. 96
2. Methods of GameEngine ..................................................................................................................................................................................................................... 96
2.1 GameEngine ........................................................................................................................................................................................................................................ 96
2.2 initEngine............................................................................................................................................................................................................................................. 96
2.3 play ......................................................................................................................................................................................................................................................... 97
2.4 basicSFMLmain ................................................................................................................................................................................................................................. 97
2.5 getRenderWindow .......................................................................................................................................................................................................................... 97
Game setup ............................................................................................................................................................................................................................................................ 97
1. enum DisplayOption ............................................................................................................................................................................................................................. 97
2. Window setting ....................................................................................................................................................................................................................................... 98
2.1 WINDOW_WIDTH ............................................................................................................................................................................................................................ 98
2.2 WINDOW_HEIGHT .......................................................................................................................................................................................................................... 98
2.3 VIEW_WIDTH ..................................................................................................................................................................................................................................... 98
2.4 VIEW_HEIGHT ................................................................................................................................................................................................................................... 98
2.5 FPS........................................................................................................................................................................................................................................................... 98
2.6 WINDOW_SETTINGS ...................................................................................................................................................................................................................... 98
3. Parameter of validation buttons ..................................................................................................................................................................................................... 98
3.1 KEY_VALIDATION_MOUSE .......................................................................................................................................................................................................... 98
3.2 KEY_VALIDATION_KEYBOARD ................................................................................................................................................................................................. 98
3.3 KEY_CANCEL ...................................................................................................................................................................................................................................... 99
4. Keyboard key setting ........................................................................................................................................................................................................................... 99
4.1 KEY_A ..................................................................................................................................................................................................................................................... 99
4.2 KEY_B ..................................................................................................................................................................................................................................................... 99
15
4.3 KEY_LEFT ............................................................................................................................................................................................................................................. 99
4.4 KEY_RIGHT .......................................................................................................................................................................................................................................... 99
4.5 KEY_UP .................................................................................................................................................................................................................................................. 99
4.6 KEY_DOWN ......................................................................................................................................................................................................................................... 99
5. Default value for SFML components ............................................................................................................................................................................................. 99
5.1 DEFAULT_SFML_TEXT_SIZE ....................................................................................................................................................................................................... 99
5.2 DEFAULT_SFML_TEXT_COLOR .............................................................................................................................................................................................. 100
5.3 DEFAULT_SFML_SELECTED_TEXT_COLOR ...................................................................................................................................................................... 100
5.4 DEFAULT_MSG_BOX_TEXT_COLOR ...................................................................................................................................................................................... 100
5.5 DEFAULT_MSG_BOX_SELECTED_TEXT_COLOR ............................................................................................................................................................. 100
5.6 DEFAULT_RPG_DIALOG_TEXT_COLOR .............................................................................................................................................................................. 100
5.7 DEFAULT_RPG_DIALOG_SELECTED_TEXT_COLOR ...................................................................................................................................................... 100
5.8 DEFAULT_BUTTON_TEXT_COLOR ....................................................................................................................................................................................... 100
6. Game information ............................................................................................................................................................................................................................... 100
5.1 MAJOR ................................................................................................................................................................................................................................................ 101
5.2 MINOR ................................................................................................................................................................................................................................................ 101
5.3 getGameVersion ............................................................................................................................................................................................................................ 101
5.4 GAME_NAME ................................................................................................................................................................................................................................... 101
5.5 GAME_AUTHOR ............................................................................................................................................................................................................................. 101
7. Admob setting....................................................................................................................................................................................................................................... 101
7.1 Ad Id .................................................................................................................................................................................................................................................... 101
7.1.1 kAdMobAppID .......................................................................................................................................................................................................................... 101
7.1.2 kBannerAdUnit ........................................................................................................................................................................................................................ 101
7.1.3 kRewardedVideoAdUnit ...................................................................................................................................................................................................... 102
7.2 Banner size ....................................................................................................................................................................................................................................... 102
7.2.1 kBannerWidth .......................................................................................................................................................................................................................... 102
7.2.2 kBannerHeight ......................................................................................................................................................................................................................... 102
7.3 Target audience ............................................................................................................................................................................................................................. 102
7.3.1 kBirthdayDay ............................................................................................................................................................................................................................ 102
7.3.2 kBirthdayMonth ...................................................................................................................................................................................................................... 102
7.3.3 kBirthdayYear .......................................................................................................................................................................................................................... 102
7.3.4 kKeywords ................................................................................................................................................................................................................................. 102
8. Path of the resource files ................................................................................................................................................................................................................. 102
8.1 ASSETS_DIR ..................................................................................................................................................................................................................................... 102
8.2 GUI_DIR .............................................................................................................................................................................................................................................. 103
8.3 FONT_DIR ......................................................................................................................................................................................................................................... 103
8.4 SPRITES_DIR ................................................................................................................................................................................................................................... 103
8.5 TILES_DIR ......................................................................................................................................................................................................................................... 103
8.6 SFX_DIR .............................................................................................................................................................................................................................................. 103
8.7 MUSIC_DIR ....................................................................................................................................................................................................................................... 103
8.8 TMX_RSC_DIR ................................................................................................................................................................................................................................. 103
9. Game package name (Android) .................................................................................................................................................................................................... 103
10. Backup file path ............................................................................................................................................................................................................................. 104
16
10.1 DATA_PARENT_DIR ............................................................................................................................................................................................................... 104
Root of game datas files. .............................................................................................................................................................................................................................. 104
10.2 GAME_DATA_FILE .................................................................................................................................................................................................................. 104
10.3 CONFIG_FILE ............................................................................................................................................................................................................................. 104
10.4 GAME_PAD_FILE ..................................................................................................................................................................................................................... 104
Activity ................................................................................................................................................................................................................................................................. 104
1. class GameActivity .............................................................................................................................................................................................................................. 104
2. Elements of GameActivity ............................................................................................................................................................................................................... 104
2.1 GameActivity ................................................................................................................................................................................................................................... 104
2.2 m_gameScene .................................................................................................................................................................................................................................. 105
2.3 onUpdate ........................................................................................................................................................................................................................................... 105
2.4 onDraw .............................................................................................................................................................................................................................................. 105
Game Level ......................................................................................................................................................................................................................................................... 105
1. Level .......................................................................................................................................................................................................................................................... 105
2. Integration of a level .......................................................................................................................................................................................................................... 105
3. Elements to manage levels ............................................................................................................................................................................................................. 105
3.1 namespace level ............................................................................................................................................................................................................................ 105
3.2 enum LevelId .................................................................................................................................................................................................................................. 105
3.3 getLevelMap .................................................................................................................................................................................................................................... 106
Game language ................................................................................................................................................................................................................................................. 106
1. Languages ............................................................................................................................................................................................................................................... 106
2. Elements to manage languages .................................................................................................................................................................................................... 106
2.1 namespace lang.............................................................................................................................................................................................................................. 106
2.2 enum GameLanguage .................................................................................................................................................................................................................. 106
Game Dialog Box .............................................................................................................................................................................................................................................. 107
1. class GameDialog................................................................................................................................................................................................................................. 107
2. Elements of GameDialog .................................................................................................................................................................................................................. 107
2.1 GameDialog ...................................................................................................................................................................................................................................... 107
2.2 enum DialogIndex ......................................................................................................................................................................................................................... 107
2.3 linkArrayToEnum ......................................................................................................................................................................................................................... 108
2.4 step ...................................................................................................................................................................................................................................................... 108
2.5 setDialog ............................................................................................................................................................................................................................................ 109
2.6 setMouseInCollison ...................................................................................................................................................................................................................... 109
2.7 draw .................................................................................................................................................................................................................................................... 109
2.8 getDialogIndex ............................................................................................................................................................................................................................... 109
2.9 getMouseInCollison ..................................................................................................................................................................................................................... 109
2.10 showDialog ................................................................................................................................................................................................................................ 109
17
Getting started guide
1. Introduction
Welcome to the is::Engine game engine user guide. The purpose of this guide is to detail how the API works.
2. About the engine
is::Engine is a tool that relies on the mechanisms of the SFML library to work. So if you want to use this tool it is
strongly advised to know at least the basics of SFML. The objective of this engine is to offer you features that allow you
to create a game with the most flexibility possible and to easily carry it on various platforms (Web-HTML5, Windows,
Linux, Android).
The engine is directly delivered with an IDE to avoid reconfigurations and to start quickly with this one. Note that each
IDE with which the engine is delivered makes it possible to carry your project on a target platform. So the Android
Studio project lets you use the engine to develop on Android.
The header which gives access to the engine is: isEngine/core/GameEngine.h.
3. Engine structure
3.1 app_src
Directory that contains the source code of the game.
Description of these subdirectories:
activity: Contains the Activity class (click here for more information: 1) which launches the different scenes
of the game and ensures their interactions.
config: Contains the GameConfig.cpp file (click here for more information: 1) which allows you to define the
general parameters of the game. It also contains the file ExtraConfig.h which allows to activate / deactivate
certain engine functionality.
gamesystem_ext: Contains a class derived (click here for more information: 1) from GameSystem (click
here for more information: 1) which allows you to manipulate the game data (save, load, etc.).
language: Contains the GameLanguage.cpp file (click here for more information: 1) which allows you to
manage everything related to the languages of the game.
levels: Contains the levels and the Level.h file (click here for more information: 1) which allows you to
integrate them into the game.
objects: Contains the objects that will be used in the different scenes.
isEngine
app_src
config
assets
scenes
objects
levels
language
Game
gamesyste
m_ext
main.cpp
File
18
scenes: Contains the different scenes of the game (click here for more information: 1) (Introduction, Main
menu, ...).
3.2 isEngine
Directory that contains the source code of the game engine.
3.3 assets
Directory of game resource files (music, sound effects, images ...).
3.4 main.cpp file
This file contains the function which allows to launch the program.
3.4.1 main
int main()
Source Code
The main function that launches the game engine. Inside you will find GameEngine game; which initializes the game
engine.
Return 0 when the program is finished and another value if there is an error during execution.
3.4.2 game.play
game.play()
Source Code
Allows to use the main loop of the game engine which allows you to launch the different game scenes (Introduction,
Main menu, ...).
3.4.3 game.basicSFMLmain
game.basicSFMLmain()
Source Code
Displays a classic SFML window. This function allows you to use your own rendering loop with the engine. Very useful
if you want to use an SFML project already under development with the engine or to integrate your own components
into the engine.
Display
1. class GameDisplay
class GameDisplay;
Header : isEngine/system/display/GameDisplay.h
Source Code
Abstract class that allows you to create the scene of a game. A scene is a place where the objects of the game come to life
(Main Menu, Level, etc.). This class offers you functions that allow you to easily manipulate the view, apply window
events on the scene, make animations on texts and sprites, display dialog boxes, etc.
19
2. Public methods
2.1 GameDisplay
GameDisplay(GameSystemExtended &gameSysExt, sf::Color bgColor)
Source Code
Constructor which allows you to create a GameDisplay object, it takes as parameter a GameSystemExtended object
(click here for more information: 1) and the background color of the scene.
2.2 step
virtual void step() = 0
Source Code
Method which makes it possible to implement the part where the objects of the scene are updated (displacement of the
objects, detection of collision, etc).
Note: When the SDM is activated and the user does not overload this function the SDM takes care of calling this
method to automatically update the objects of the scene and the events of the window.
2.3 draw
virtual void draw() = 0
Source Code
Method which makes it possible to implement the part where the objects of the scene will be draw.
Note: When the SDM is activated and the user does not overload this function the SDM takes care of calling this
method to automatically draw the objects of the scene.
2.4 drawScreen
virtual void drawScreen()
Source Code
Method for implementing the part where the objects of the game scene will be draw.
2.5 showTempLoading
virtual void showTempLoading(float time = 3.f * is::SECOND)
Source Code
Displays a false loading screen (Useful for making transitions in the same scene).
Parameter time represents the duration (in milliseconds) of the loading.
2.6 setOptionIndex
First form :
virtual void setOptionIndex(int optionIndexValue, bool callWhenClick, float buttonScale = 1.3f)
Source Code
Allows to make animations on texts and play a sound when you change an option.
Second form :
20
virtual void setOptionIndex(int optionIndexValue)
Source Code
Allows to change an option.
2.7 setTextAnimation
First form :
virtual void setTextAnimation(sf::Text &txt, sf::Sprite &spr, int val)
Source Code
Allows to make an animation on a text and a sprite according to the choice of an option.
Second form :
virtual void setTextAnimation(sf::Text &txt, int &var, int val)
Source Code
Allows to make an animation on a text according to the choice of an option.
2.8 setView
First form :
virtual void setView()
Second form :
virtual void setView(sf::Vector2f v)
Third form :
virtual void setView(float x, float y)
Source Code
Updates the position of the view in the scene.
2.9 setViewVarX
virtual void setViewVarX(float val)
Source Code
Allows to define the variable m_viewX.
2.10 setViewVarY
virtual void setViewVarY(float val)
Source Code
Allows to define the variable m_viewY.
2.11 setViewVarXY
virtual void setViewVarXY(float x, float y)
Source Code
21
Allows to define the variable m_viewX and m_viewY.
2.12 setViewSize
virtual void setViewSize(sf::Vector2f v)
virtual void setViewSize(float x, float y);
Source Code
Allows to set view position.
2.13 setWindowSize
virtual void setWindowSize(sf::Vector2u v, bool updateViewSize = false)
Source Code
Allows to redefine the window size (only for PC).
2.14 setWindowTitle
virtual void setWindowTitle(const sf::String &title)
Source Code
Allows to define the window title.
2.15 setWindowBgColor
virtual void setWindowBgColor(sf::Color color)
Source Code
Allows to define the background color of the window.
2.16 loadParentResources
virtual bool loadParentResources()
Source Code
Loads the resources that allow you to display dialog boxes in a scene.
It is generally used in the loadResources function of a scene.
2.17 loadResources
virtual bool loadResources() = 0
Source Code
Allows you to implement the loading of resources that are used in a scene.
2.18 setIsRunning
virtual void setIsRunning(bool val)
Source Code
Allows to define the execution state of the scene.
2.19 setIsPlaying
22
virtual void setIsPlaying(bool val)
Source Code
Allows to define the m_isPlaying variable.
2.20 quitScene
virtual void quitScene(int nextScene = -1)
Source Code
Allows to exit the current scene and move to another. If no scene is filled the application stops.
2.21 setSceneStart
virtual void setSceneStart(bool val)
Source Code
Allows to define the m_sceneStart variable.
2.22 setSceneEnd
virtual void setSceneEnd(bool val)
Source Code
Allows to define the m_sceneEnd variable.
2.23 setKeyBackPressed
virtual void setKeyBackPressed(bool val)
Source Code
Allows to define the m_keyBackPressed variable.
2.24 getIsRunning
virtual bool getIsRunning() const
Source Code
Return true if a scene is running and false if not.
2.25 getIsPlaying
virtual bool getIsPlaying() const
Source Code
Return true if a scene is active and false if not.
2.26 getSceneStart
virtual bool getSceneStart() const
Source Code
Return true if a scene is at the start of execution and false if not.
2.27 getSceneEnd
23
virtual bool getSceneEnd() const
Source Code
Return true if a scene comes to an end and false if not.
2.28 getWindowIsActive
virtual bool getWindowIsActive() const
Source Code
Return true if the window is active and false if not.
2.29 getKeyBackPressed
virtual bool getKeyBackPressed() const
Source Code
Return the value of the m_keyBackPressed vraiable.
2.30 getView
virtual sf::View& getView() const
Source Code
Return the view of a scene.
2.31 getRenderWindow
virtual sf::RenderWindow& getRenderWindow()
Source Code
Return the scene execution window.
2.32 getRenderTexture
virtual sf::RenderTexture& getRenderTexture() const
Source Code
Return the surface on which we draw the objects of a scene.
2.33 getGameSystem
virtual GameSystemExtended& getGameSystem()
Source Code
Return the game system extended object.
2.34 getFontSystem
virtual sf::Font& getFontSystem()
Source Code
Return the system font.
2.35 getFontMsg
24
virtual sf::Font& getFontMsg()
Source Code
Return the dialog box font.
2.36 getSprButtonSelect
virtual sf::Sprite& getSprButtonSelect()
Source Code
Return the option selection Sprite.
2.37 getOptionIndex
virtual int getOptionIndex()
Source Code
Return the chosen option.
2.38 getSceneWidth
virtual unsigned int getSceneWidth()
Source Code
Return the width of the scene.
2.39 getSceneHeight
virtual unsigned int getSceneHeight()
Source Code
Return the height of the scene.
2.40 getDeltaTime
virtual float getDeltaTime()
Source Code
Return the execution time in seconds.
2.41 getDELTA_TIME
virtual float getDELTA_TIME() const
Source Code
Return the variable DELTA_TIME.
2.42 getSprButtonSelectScale
virtual float& getSprButtonSelectScale()
Source Code
Return the scale of the Selection Sprite.
2.43 getViewX
25
virtual float getViewX() const
Source Code
Return the x position of the view.
2.44 getViewY
virtual float getViewY() const
Source Code
Return the y position of the view.
2.45 getViewW
virtual float getViewW() const
Source Code
Return the width of the view.
2.46 getViewH
virtual float getViewH() const
Source Code
Return the height of the view.
2.47 getBgColor
virtual sf::Color& getBgColor()
Source Code
Return the background color of the scene.
2.48 inViewRec
virtual bool inViewRec(MainObject *obj, bool useTexRec = true)
Source Code
Return true if the object is in the field of vision of the view, false if not.
2.49 mouseCollision
First form
template <class T>
bool mouseCollision(T const &obj
#if defined(__ANDROID__)
, unsigned int finger = 0
#endif
)
Source Code
26
Windows, Linux : Detects if the mouse cursor collides with an object in the scene.
Android : Detects if the user touches an object in the scene.
Parameter:
obj the object with which we want to test.
finger represents the finger.
Return true if there is a collision and false if not.
Example :
if (mouseCollision(sprite))
{
// do something
}
Second form
template <class T>
bool mouseCollision(T const &obj, sf::Vector2f &position
#if defined(__ANDROID__)
, unsigned int finger = 0
#endif
)
Source Code
Windows, Linux: Detects if the mouse cursor collides with an object in the scene.
Android: Detects if the user touches an object in the scene.
Parameter:
obj the object with which we want to test.
position allows to recover the position of the collision point.
finger represents the finger.
Return true if there is a collision and false if not.
Example :
sf::Vector2f pos;
if (mouseCollision(sprite, pos))
{
float cursorXPosition = pos.x;
float cursorYPosition = pos.y;
}
2.50 SDMmanageScene
virtual void SDMmanageScene()
Source Code
27
Allows to manage all the parts of the scene (event, update, display, dialog box).
2.51 SDMmanageSceneEvents
virtual void SDMmanageSceneEvents()
Source Code
Allows to define the way in which the SDM will manage the events of the window. To change the mechanism override
this method.
2.52 SDMmanageSceneMsgAnswers
virtual void SDMmanageSceneMsgAnswers()
Source Code
Allows to define the way in which the SDM will manage the dialog box answers. To change the mechanism override
this method.
2.53 SDMcallObjectsEvents
virtual void SDMcallObjectsEvents(sf::Event &event)
Source Code
. Allows to call the event() method (the event part) of an object located in the SDM container.
2.54 SDMstep
virtual void SDMstep()
Source Code
Allows to update the objects that are in the SDM container.
2.55 SDMdraw
virtual void SDMdraw()
Source Code
Allows to draw the objects in the SDM container.
2.56 GSMplaySound
virtual void GSMplaySound(const std::string& name)
Source Code
Allows to play a sound managed by GSM.
2.57 GSMpauseSound
virtual void GSMpauseSound(const std::string& name)
Source Code
Allows to pause a sound managed by GSM.
2.58 GSMpauseSound
virtual void GSMstopSound(const std::string& name)
28
Source Code
Allows to stop sound managed by GSM.
2.59 GSMplayMusic
virtual void GSMplayMusic(const std::string& name)
Source Code
Allows to play a music managed by GSM.
2.60 GSMpauseMusic
virtual void GSMpauseMusic(const std::string& name)
Source Code
Allows to pause a music managed by GSM.
2.61 GSMstopMusic
virtual void GSMstopMusic(const std::string& name)
Source Code
Allows to stop music managed by GSM.
2.62 controlEventFocusClosing
virtual void controlEventFocusClosing()
Source Code
Handles focus and window closing events. Used in an event loop!
3. Protected elements
3.1 enum MsgAnswer
enum MsgAnswer;
Enumerator
YES
Response Yes
NO
Response No
Source Code
Represents the responses that the user can choose from the dialog box.
3.2 showMessageBox
template<class T>
void showMessageBox(T const &msgBody, bool mbYesNo = true)
Source Code
Define parameter and displays the dialog box.
Parameter:
msgBody the message that will be displayed to the user.
29
mbYesNo true displays a YES NO dialog box and false displays just an OK button.
3.3 updateMsgBox
void updateMsgBox(int sliderDirection, bool rightSideValidation, float const &DELTA_TIME, sf::Color textDefaultColor =
DEFAULT_MSG_BOX_TEXT_COLOR, sf::Color textSelectedColor = DEFAULT_MSG_BOX_SELECTED_TEXT_COLOR)
Source Code
Updates the information in the dialog box.
Parameter :
sliderDirection allows to manage GameSlider direction (click here 1 fore more information).
rightSideValidation allows you to validate an option by clicking on the right side of a screen.
textDefaultColor message text color.
textSelectedColor button text color.
3.4 updateTimeWait
void updateTimeWait(float const &DELTA_TIME)
Source Code
Updates the counter which allows the user to wait after choosing an option. This avoids the choices in loops.
3.5 drawMsgBox
void drawMsgBox()
Source Code
Displays the dialog box.
SDM (Step and Draw Manager)
1. class SDM
class SDM;
Header : isEngine/system/display/SDM.h
Source Code
Parent class that allows a scene to use the functions that automatically update and display the objects of a scene. It also
allows to manage the display depth of objects.
2. Publics elements of SDM
2.1 m_SDMsceneObjects
std::vector<std::shared_ptr<MainObject>> m_SDMsceneObjects
Source Code
Container which allows to store the objects (derived from MainObject class) of the scene which will be managed by the
SDM.
30
2.2 SDMgetObject
MainObject* SDMgetObject(const std::string& name)
Source Code
Return an object which is in the container according to its name.
Exemple :
auto player = SDMgetObject("Player");
player->setX(777.f);
2.3 SDMaddSceneObject
template <class T>
void SDMaddSceneObject(std::shared_ptr<T> obj, bool callStepFunction = true, bool callDrawFunction = true, const
std::string& name = "null", bool callEventFunction = false)
Source Code
Allows to add an object to the container.
Parameter :
obj the object to add.
callStepFunction lets know if the SDM should update the object.
callDrawFunction lets know if the SDM should draw the object.
name allows to give a name to the object during the addition.
callEventFunction lets know if the SDM should call the object's event method.
2.4 SDMaddSprite
virtual void SDMaddSprite(sf::Texture &tex, const std::string& name , float x, float y, bool center = false, int depth =
DepthObject::NORMAL_DEPTH)
Source Code
Allows you to add a SFML Sprite in the container. It will not be part of the objects to be updated but of those that will be
displayed. The Sprite will be associated with a MainObject object.
2.5 SDMsetObjDepth
virtual void SDMsetObjDepth(const std::string& name, int depth)
virtual void SDMsetObjDepth(MainObject *obj, int depth)
Source Code
Allows to define the display depth of an object.
Game Sound
1. class GameSound
31
class GameSound;
Header : isEngine/system/sound/GameSound.h
Source Code
Class that allows to use sounds in the game.
2. Publics elements of GameSound
2.1 GameSound
GameSound(const std::string& soundName, const std::string& filePath)
Source Code
Constructor that allows to load a sound and give it a name.
2.2 loadResources
void loadResources(const std::string& filePath)
Source Code
Allows to load the sound. This function is not supported when developing on the web (HTML)!
2.3 getSoundBuffer
sf::SoundBuffer& getSoundBuffer()
Source Code
Return Sound Buffer object.
2.4 getSound
sf::Sound& getSound()
Source Code
Return Sound object.
Game Music
1. class GameMusic
class GameMusic;
Header : isEngine/system/sound/GameMusic.h
Source Code
Class that allows to use musics in the game.
2. Publics elements of GameMusic
2.1 GameMusic
GameMusic(const std::string& musicName, const std::string& filePath)
Source Code
32
Constructor that allows to load a music and give it a name.
2.2 loadResources
void loadResources(const std::string& filePath)
Source Code
Allows to load the music. This function is not supported when developing on the web (HTML)!
2.3 getMusic
sf::Music& getMusic()
Source Code
Return Music object.
GSM (Game Sound Manager)
1. class GSM
class GSM;
Header : isEngine/system/sound/GSM.h
Source Code
Parent class that allows a scene to add and use sounds and musics without initializing SFML objects.
2. Publics elements of GSM
2.1 GSM Containers
std::vector<std::shared_ptr<GameSound>> m_GSMsound
std::vector<std::shared_ptr<GameMusic>> m_GSMmusic
Source Code
Container which allows to store the sounds and musics of the scene which will be managed by the GSM.
2.2 GSMaddSound
virtual void GSMaddSound(const std::string& filePath, const std::string& name)
Source Code
Allows to add a sound to the container.
Parameter :
name sound name.
filePath sound file path.
2.3 GSMaddMusic
virtual void GSMaddMusic(const std::string& filePath, const std::string& name)
Source Code
33
Allows to add a music to the container.
Parameter :
name music name.
filePath music file path.
2.4 GSMgetSound
virtual sf::Sound* GSMgetSound(const std::string& name)
Source Code
Return a sound that is in the container according to its name.
2.5 GSMgetMusic
virtual sf::Music* GSMgetMusic(const std::string& name)
Source Code
Return a music that is in the container according to its name.
Game Texture
1. class GameTexture
class GameTexture;
Header : isEngine/system/graphic/GameTexture.h
Source Code
Class that allows to use textures in the game.
2. Publics elements of GameTexture
2.1 GameTexture
GameTexture(const std::string& textureName, const std::string& filePath)
Source Code
Constructor that allows to load a texture and give it a name.
2.2 loadResources
void loadResources(const std::string& filePath)
Source Code
Allows to load the texture. This function is not supported when developing on the web (HTML)!
2.3 getTexture
sf::Texture& getTexture()
Source Code
Return texture object.
34
Game Font
1. class GameFont
class GameFont;
Header : isEngine/system/graphic/GameFont.h
Source Code
Class that allows to use fonts in the game.
2. Publics elements of GameFont
2.1 GameFont
GameFont(const std::string& fontName, const std::string& filePath, float fontSize
#if defined(IS_ENGINE_HTML_5)
= is::GameConfig::DEFAULT_SFML_TEXT_SIZE
#endif
)
Source Code
Constructor that allows to load a font and give it a name. The fontSize must be entered when developing on the Web
(HTML)!
2.2 loadResources
void loadResources(const std::string& filePath)
Source Code
Allows to load the font. This function is not supported when developing on the web (HTML)!
2.3 getFont
sf::Font& getFont()
Source Code
Return font object.
GRM (Graphic Resource Manager)
1. class GRM
class GRM;
Header : isEngine/system/graphic/GRM.h
Source Code
Parent class that allows a scene to add and use fonts and textures without initializing SFML objects.
35
2. Publics element of GRM
2.1 GRM Containers
std::vector<std::shared_ptr<GameFont>> m_GRMfont
std::vector<std::shared_ptr<GameTexture>> m_GRMtexture
Source Code
Container which allows to store the fonts and textures of the scene which will be managed by the GRM.
2.2 GRMaddFont
virtual void GRMaddFont(const std::string& name, const std::string& filePath, float fontSize
#if defined(IS_ENGINE_HTML_5)
= is::GameConfig::DEFAULT_SFML_TEXT_SIZE
#endif
)
Source Code
Allows to add a font to the container. The fontSize must be entered when developing on the Web (HTML)!
Parameter :
name font name.
filePath font file path.
2.3 GRMaddTexture
virtual void GRMaddTexture(const std::string& name, const std::string& filePath)
Source Code
Allows to add a texture to the container.
Parameter :
name texture name.
filePath texture file path.
2.4 GSMgetFont
virtual sf::Font* GRMgetFont(const std::string& name)
Source Code
Return a font that is in the container according to its name.
2.5 GSMgetTexture
virtual sf::Texture* GRMgetTexture(const std::string& name)
Source Code
Return a texture that is in the container according to its name.
36
Transition Effect
1. class Transition Effect
class TransitionEffect;
Header : isEngine/system/graphic/TransitionEffect.h
Source Code
Class that allows to make transition effects of type Fade In and Fade Out.
2. Publics element of Transition Effect
2.1 Enum Transition
enum Transition;
Transition
FADE_IN
Represent fade out transition
FADE_OUT
Represent fade in transition
Source Code
Represent the type of transition that will be.
2.2 TransitionEffect
TransitionEffect(is::GameDisplay *scene)
Source Code
Constructor which takes as parameter the scene in which the transition will be used.
2.3 step
void step(float const &DELTA_TIME)
Source Code
Allows to update object (transition).
2.4 draw
void draw(is::Render &render);
Source Code
Allows to draw object (transition).
2.5 setType
void setType(int type);
Source Code
Allows to define transition type.
2.6 getTransitionEnd
37
bool getTransitionEnd(int type) const
Source Code
Allows to know if the animation of the transition is finished.
Entities
1. class MainObject
class MainObject;
Header: isEngine/system/entity/MainObject.h
Source Code
Basic class to create the objects (Character, Tiles, Button, etc) that will be used in the scenes. It offers you functions
which allow you to control an object (displacements, detections of collision between objects, calculation of distance,
etc) and many other things which are linked to the game play of the game.
2. Publics elements of MainObjet
2.1 MainObject
First form
MainObject()
Source Code
Default constructor of the class.
Second form
MainObject(float x, float y)
Source Code
Constructor that initializes the object with a starting point.
Third form
MainObject(sf::Sprite &spr, float x = 0.f, float y = 0.f)
Source Code
Constructor that initializes the object with a Sprite and a starting point.
Forth form
MainObject(sf::Texture &tex, float x, float y , bool center = false)
Source Code
Constructor that initializes the object with a Texture, starting point and center Sprite.
2.2 instanceNumber
static int instanceNumber;
Source Code
38
Return the number of instances of the class.
2.3 m_SDMcallStep
bool m_SDMcallStep
Source Code
Lets know if SDM can use the object's step() (update) method.
2.4 m_SDMcallDraw
bool m_SDMcallDraw
Source Code
Lets know if SDM can use the object's draw() method.
2.5 m_SDMcallEvent
bool m_SDMcallEvent
Source Code
Lets know if the SDM can use the object's event() method.
2.6 step
virtual void step(float const &DELTA_TIME)
Source Code
Allow to update the object. To be overridden in a child of MainObject!
2.7 event
virtual void event(sf::Event &ev)
Source Code
Allow to implement the event part of the object. To be overloaded in a child class of MainObject if the variable
"m_SDMcallEvent" is true!
2.8 setXStart
virtual void setXStart(float x)
Source Code
Defines the starting position x.
2.9 setYStart
virtual void setYStart(float y)
Source Code
Defines the starting position y.
2.10 setXPrevious
virtual void setXPrevious(float x)
39
Source Code
Defines the previous position x.
2.11 setYPrevious
virtual void setYPrevious(float y)
Source Code
Defines the previous position y.
2.12 setStartPosition
virtual void setStartPosition(float x, float y)
Source Code
Sets the x and y start position.
2.13 setX
virtual void setX(float x)
Source Code
Define position x.
2.14 setY
virtual void setY(float y)
Source Code
Define position y.
2.15 moveX
virtual void moveX(float x)
Source Code
Moves the object on the x-axis.
2.16 moveY
virtual void moveY(float y)
Source Code
Moves the object on the y-axis.
2.17 setPosition
virtual void setPosition(float x, float y)
Source Code
Set the x and y position.
2.18 setSpriteScale
virtual void setSpriteScale(float x, float y)
40
Source Code
Set the x and y scale of the object sprite.
2.19 setSpeed
virtual void setSpeed(float val)
Source Code
Set the speed of the object.
2.20 setHsp
virtual void setHsp(float val)
Source Code
Set horizontal speed.
2.21 setVsp
virtual void setVsp(float val)
Source Code
Set vertical speed.
2.22 setAngularMove
virtual void setAngularMove(float const &DELTA_TIME, float speed, float angle)
Source Code
Allows to move the object according to an angle and a speed.
2.23 setFrame
virtual void setFrame(float val)
Source Code
Set the frame of the object.
2.24 setImageXscale
virtual void setImageXscale(float val)
Source Code
Set the x scale of the object.
2.25 setImageYscale
virtual void setImageYscale(float val)
Source Code
Set the y scale of the object.
2.26 setImageScale
virtual void setImageScale(float val)
41
Source Code
Set the x and y scale of the object with the same value.
2.27 setImageScaleX_Y
virtual void setImageScale(float x, float y)
Source Code
Set the x and y scale of the object.
2.28 setImageAngle
virtual void setImageAngle(float val)
Source Code
Set the angle of the object.
2.29 setXOffset
virtual void setXOffset(float val)
Source Code
Define the x offset of the object.
2.30 setYOffset
virtual void setYOffset(float val)
Source Code
Define the y offset of the object.
2.31 setXYOffset
virtual void setXYOffset(float x, float y)
Source Code
Defines the offset x and y of the object.
2.32 setXYOffset
virtual void setXYOffset()
Source Code
Define the x and y offset of the object based on the center of the object sprite.
2.33 setTime
void setTime(float x)
Source Code
Set the value of the object's m_time variable.
2.34 setImageAlpha
virtual void setImageAlpha(int val)
42
Source Code
Set the alpha image of the object.
2.35 setImageIndex
virtual void setImageIndex(int val)
Source Code
Define the sub image of the object.
2.36 setMaskW
virtual void setMaskW(unsigned int val)
Source Code
Set the width of the object's collision mask.
2.37 setMaskH
virtual void setMaskH(unsigned int val)
Source Code
Set the height of the object's collision mask.
2.38 setRectangleMask
virtual void setRectangleMask(int width, int height)
Source Code
Set the width and height of the rectangle collision mask and use it as the default mask.
2.39 setCircleMask
virtual void setCircleMask(float raduis)
Source Code
Set the radius of the circle collision mask and use it as the default mask.
2.40 setIsActive
virtual void setIsActive(bool val)
Source Code
Defines the activity state of the object.
2.41 updateCollisionMask
First form :
virtual void updateCollisionMask()
Source Code
Updates the information (size, position, etc) of the collision mask.
Second form:
43
virtual void updateCollisionMask(int x, int y)
Source Code
Updates the position of the collision mask according to a point x and y different from that of the object.
2.42 centerCollisionMask
virtual void centerCollisionMask(int x, int y)
Source Code
Center the position of the collision mask according to a point x and y.
2.43 updateSprite
First form
virtual void updateSprite()
Source Code
Updates the sprite of the object with the values of the variables (alpha, scale, etc.) which are in the object.
Second form
virtual void updateSprite(float x, float y, float angle = 0.f, int alpha = 255, float xScale = 1.f, float yScale = 1.f)
Source Code
Updates the sprite of the object with external values.
2.44 draw
virtual void draw(is::Render &surface)
Source Code
Displays the object.
2.45 drawMask
virtual void drawMask(is::Render &surface, sf::Color color = sf::Color::Blue)
Source Code
Allows to display the collision mask that has been defined (Rectangle or Circle) for the object.
2.46 getMask
virtual const Rectangle& getMask() const noexcept
Source Code
Return the rectangle (default) collision mask.
2.47 getCircleMask
virtual const Circle& getCircleMask() const noexcept
Source Code
Return the circle collision mask.
44
2.48 getX
virtual float getX() const
Source Code
Return the x position of the object.
2.49 getY
virtual float getY() const
Source Code
Return the y position of the object.
2.50 getXStart
virtual float getXStart() const
Source Code
Return the x start position of the object.
2.51 getYStart
virtual float getYStart() const
Source Code
Return the y start position of the object.
2.52 getXPrevious
virtual float getXPrevious() const
Source Code
Return the previous position x of the object.
2.53 getYPrevious
virtual float getYPrevious() const
Source Code
Return the previous position y of the object.
2.54 distantToPoint
virtual float distantToPoint(float x, float y) const
Source Code
Return the distance between the object and a point x and y.
2.55 distantToObject
virtual float distantToObject(std::shared_ptr<MainObject> const &other, bool useSpritePosition) const
Source Code
Return the distance between the object and another.
45
Parameter if useSpritePosition is true we use the position of the sprite of the object to do the test if not we use the
position x, y of the object.
2.56 pointDirection
First form
virtual float pointDirection(float x, float y) const
Source Code
Return the direction (angle) of the object relative to a point.
Second form
virtual float pointDirection(std::shared_ptr<MainObject> const &other) const
Source Code
Return the direction (angle) of the object relative to another. Here the other object is a smart pointer.
2.57 pointDirectionSprite
First form
virtual float pointDirectionSprite(float x, float y) const
Source Code
Return the direction (angle) of the object's sprite relative to a point.
Second form
virtual float pointDirectionSprite(std::shared_ptr<MainObject> const &other) const
Source Code
Return the direction (angle) of the object's sprite relative to another.
2.58 getSpeed
virtual float getSpeed() const
Source Code
Return object speed.
2.59 getHsp
virtual float getHsp() const
Source Code
Return the horizontal speed of the object.
2.60 getVsp
virtual float getVsp() const
Source Code
Return the vertical speed of the object
2.61 getFrame
46
virtual float getFrame() const
Source Code
Return the number of the sub-image that is being displayed.
2.62 getFrameStart
virtual float getFrameStart() const
Source Code
Return the number of the start sub picture.
2.63 getFrameEnd
virtual float getFrameEnd() const
Source Code
Return the number of the end sub picture.
2.64 getImageXscale
virtual float getImageXscale() const
Source Code
Return the object's x-scale.
2.65 getImageYscale
virtual float getImageYscale() const
Source Code
Return the object's y-scale.
2.66 getImageScale
virtual float getImageScale() const
Source Code
Return the object's scale.
2.67 getImageAngle
virtual float getImageAngle() const
Source Code
Return the angle of the object image.
2.68 getXOffset
virtual float getXOffset() const
Source Code
Return the object x offset.
2.69 getYOffset
47
virtual float getYOffset() const
Source Code
Return the object y offset.
2.70 getTime
virtual float getTime() const
Source Code
Return the value of the variable m_time.
2.71 getInstanceId
virtual int getInstanceId() const
Source Code
Return the object number.
2.72 getMaskW
virtual unsigned int getMaskW() const
Source Code
Return the width of the collision mask.
2.73 getMaskH
virtual unsigned int getMaskH() const
Source Code
Return the height of the collision mask.
2.74 getIsActive
virtual bool getIsActive() const
Source Code
Return the state of the object.
2.75 getImageAlpha
virtual int getImageAlpha() const
Source Code
Return the alpha image of the object.
2.76 getImageIndex
virtual int getImageIndex() const
Source Code
Return the image index.
2.77 getSpriteWidth
48
virtual int getSpriteWidth() const
Source Code
Return the width of the sprite.
2.78 getSpriteHeight
virtual int getSpriteHeight() const
Source Code
Return the height of the sprite.
2.79 getSpriteX
virtual float getSpriteX() const
Source Code
Return the x position of the sprite.
2.80 getSpriteY
virtual float getSpriteY() const
Source Code
Return the y position of the sprite.
2.81 getTextureWidth
virtual int getTextureWidth() const
Source Code
Return the width of the sprite’s Texture.
2.82 getTextureHeight
virtual int getTextureHeight() const
Source Code
Return the height of the sprite’s Texture.
2.83 getSpriteCenterX
virtual int getSpriteCenterX() const
Source Code
Return the x center of the sprite.
2.84 getSpriteCenterY
virtual int getSpriteCenterY() const
Source Code
Return the y center of the sprite.
2.85 getSpriteNumberSubImage
49
virtual int getSpriteNumberSubImage(int subImageWidth) const
Source Code
Return the number of sub-images of a sprite (on the horizontal axis). subImageWidth represent the size of sub-image
(32 pixels).
2.86 placeMetting
First form
virtual bool placeMetting(int x, int y, MainObject const *other)
Source Code
Return true if there is a collision with another object, false if not.
Second form
virtual bool placeMetting(int x, int y, std::shared_ptr<MainObject> const &other)
Source Code
Return true if there is a collision with another object, false if not. Here the other object is a smart pointer.
2.87 inViewRec
bool inViewRec(sf::View const &view, bool useTexRec = true)
Source Code
Lets know if the object is in the rectangle of the view. If the useTexRec parameter is true, the sprite rectangle will be
used to do the test otherwise the rectangle mask will be used.
2.88 getSprite
virtual sf::Sprite& getSprite()
Source Code
Return the object sprite.
2.89 setFrameLimit
virtual void setFrame(float frameStart, float frameEnd = -1.f)
Source Code
Defines the start and end image which will be used to animate the sprite of the object.
3. Other functions of MainObject
3.1 instanceExist
First form
template<class T>
bool instanceExist(std::shared_ptr<T> const &obj)
Source Code
Return true if the instance exists, false if not.
Second form
50
template<class T>
bool instanceExist(T const *obj)
Source Code
Return true if the instance exists, false if not.
3.2 operator()
Position comparator
class CompareX;
Source Code
Functor which is used to sort the objects compared to their position x.
bool operator()(std::shared_ptr<MainObject> const &a, std::shared_ptr<MainObject> const &b) const
bool operator()(MainObject const *a, MainObject const *b) const
Source Code
Used to sort objects according to their x positions.
Depth comparator
class CompareDepth;
Source Code
Functor which is used to sort objects according to their depth.
bool operator()(std::shared_ptr<MainObject> const &a, std::shared_ptr<MainObject> const &b) const
Source Code
Used to sort objects according to their depths.
3.3 sortObjArrayByX
template<class T>
void sortObjArrayByX(std::list<std::shared_ptr<T>> &v)
Source Code
Sort an array (std::list) of objects by x position.
3.4 sortObjArrayByDepth
template<class T>
void sortObjArrayByDepth(std::list<std::shared_ptr<T>> &v)
Source Code
Sort an array (std::list) of objects by depth.
3.5 operator<
bool operator<(const MainObject *a, const MainObject &b);
51
bool operator<(const MainObject &b, const MainObject *a);
bool operator<(std::shared_ptr<MainObject> const &a, const MainObject &b)
bool operator<(const MainObject &b, std::shared_ptr<MainObject> const &a)
Source Code
Return true if the position of object A is less than that of B, false if not.
Forms for collision masks
Header : isEngine/system/entity/Form.h
1. class Rectangle
class Rectangle;
Source Code
Represents the rectangle collision mask. These members m_left, m_top, m_right, m_bottom allows to define the size of
the mask.
2. class Circle
class Circle;
Source Code
Represents the circle collision mask. These members m_x, m_y, m_raduis allows to define the position and raduis of
the circle.
Circle()
Source Code
Default constructor.
The Parent Classes of MainObject
1. class DepthObject
class DepthObject;
Header : isEngine/system/entity/parents/DephObject.h
Source Code
Class that provides methods for managing the display depth of objects in a scene.
1.1 enum Depth
enum Depth;
Enumerator
VERY_BIG_DEPTH
Very big depth
BIG_DEPTH
Big depth
52
NORMAL_DEPTH
Normal depth
SMALL_DEPTH
Small depth
VERY_SMALL_DEPTH
Very small depth
Source Code
Represents the depth level of an object.
1.2 DepthObject
DepthObject(int Depth)
Source Code
Constructor to define a depth.
1.3 setDepth
virtual void setDepth(int val)
Source Code
Set the depth of the object.
1.4 getDepth
virtual int getDepth() const
Source Code
Return the depth of the object.
2. class Destructible
class Destructible;
Header : isEngine/system/entity/parents/Destructible.h
Source Code
Class that offers methods to manage the destruction of an object.
2.1 Destructible
Destructible()
Source Code
Default constructor.
2.2 setDestroyed
virtual void setDestroyed()
Source Code
Starts the destruction of an object.
2.3 isDestroyed
virtual bool isDestroyed() const
53
Source Code
Return the state of the object.
3. class Visibility
class Visibility;
Header : isEngine/system/entity/parents/Visibility.h
Source Code
Class that offers methods to manage the visibility of an object.
3.1 Visibility
explicit Visibility(bool defaultVisibility = true)
Source Code
Class constructor.
3.2 setVisible
void setVisible(bool value)
Source Code
Set the visibility of the object.
3.3 getVisible
bool getVisible() const
Source Code
Return the state of the object.
4. class Health
class Health;
Header : isEngine/system/entity/parents/Health.h
Source Code
Class that provides methods for managing the health of an object.
4.1 Health
First form
Health(int health)
Source Code
Constructor of the class takes as a parameter the health to be attributed to the object. Here the maximum health value is
equal to the defined health.
Second form
Health(int health, int maxHealth)
54
Source Code
Class constructor takes as a parameter the health to be assigned to the object and the maximum value.
4.2 setHealth
virtual void setHealth(int val)
Source Code
Define the health of the object.
4.3 setMaxHealth
virtual void setMaxHealth(int val)
Source Code
Defines the maximum health (the limit not to be exceeded) of the object.
4.4 addHealth
virtual void addHealth(int val = 1)
Source Code
Add health to the object. Can also be used to retake it if you put a negative value.
4.5 getHealth
virtual int getHealth() const
Source Code
Return the health of the object.
4.6 getMaxHealth
virtual int getMaxHealth() const
Source Code
Return the maximum health (the limit not to be exceeded) of the object.
5. class HurtEffect
class HurtEffect;
Header : isEngine/system/entity/parents/HurtEffect.h
Source Code
Class that offers methods to make an invulnerability effect on an object. That is, make the object blink for a certain time
(e.g. when the player is attacked by an enemy he becomes invulnerable by blinking for a limited time).
5.1 HurtEffect
HurtEffect(sf::Sprite &sprParent) :
Source Code
Class constructor takes as parameter the sprite on which the invulnerability effect will be effected.
55
5.2 hurtStep
void hurtStep(float const &DELTA_TIME)
Source Code
Allows to make the invulnerability animation.
5.3 setIsHurt
void setIsHurt(float durration = 100.f)
Source Code
Defines the duration (in millisecond) of the object's invulnerability.
5.4 getIsHurt
bool getIsHurt() const
Source Code
Return true if the object is invulnerable, false if not.
6. class ScorePoint
class ScorePoint;
Header : isEngine/system/entity/parents/ScorePoint.h
Source Code
Class that offers methods for managing the score to be assigned to an object (e.g. each enemy has a particular score
point when it is created which is added to the player's overall score when he is defeated).
6.1 ScorePoint
explicit ScorePoint(int point = 0)
Source Code
Class constructor, takes as a parameter the point to assign to the object.
6.2 setScorePoint
virtual void setScorePoint(int point)
Source Code
Set object score point.
6.3 getScorePoint
virtual int getScorePoint() const
Source Code
Return the score point assigned to the object.
7. class Step
class Step;
56
Header : isEngine/system/entity/parents/Step.h
Class that offers methods to manage the different steps of an object (e.g. to take off a rocket you have to go through
several steps).
7.1 Step
explicit Step(int step = 0)
Source Code
Class constructor.
7.2 setStep
virtual void setStep(int val)
Source Code
Defines the step of the object.
7.3 addStep
virtual void addStep()
Source Code
Advance the object step.
7.4 reduceStep
virtual void reduceStep()
Source Code
Reduce the object step.
7.5 getStep
virtual int getStep() const
Source Code
Return the step at which the object is.
8. class Name
class Name;
Header : isEngine/system/entity/parents/Name.h
Parent class that provides methods for managing the name of an object.
8.1 Name
explicit Name(const std::string& name = "Unknown")
Source Code
Constructor used to define the name of the object.
8.2 setName
57
virtual void setName(const std::string& soundName)
Source Code
Allows to define the name of the object.
8.3 getName
virtual const std::string getName() const noexcept
Source Code
Return the name of the object.
9. class FilePath
class FilePath;
Header : isEngine/system/entity/parents/FilePath.h
Parent class that provides methods for managing the path of a file.
9.1 FilePath
FilePath(const std::string& filePath)
Source Code
Constructor of the class, it takes as parameter the path of the file to load.
9.2 setFilePath
virtual void setFilePath(const std::string& filePath)
Source Code
Allows to define the file path.
9.3 getFilePath
virtual const std::string getFilePath() const noexcept
Source Code
Return file path.
9.4 getFileIsLoaded
bool getFileIsLoaded() const
Source Code
Return true when the file has been loaded false otherwise.
10. class Type
class Type;
Header : isEngine/system/entity/parents/Type.h
Parent class that offers methods to manage the type of a class based on an enum.
10.1 Type
58
Type(int type)
Source Code
Constructor of the class, it takes the type (enum value) as parameter.
10.2 setType
virtual void setType(int type)
Source Code
Allows to define the type of object.
10.3 getType
virtual int getType() const
Source Code
Return the type of object.
The Backgroud
1. class Background
class Background;
Header : isEngine/system/entity/Background.h
Source Code
This Class allows to draw a Sprite as a background, with the possibility of using it to fill a scene and to scroll it with
horizontal and vertical speed.
2. Public methods
2.1 Background
Background(sf::Texture &tex, float x, float y, is::GameDisplay *scene, float hSpeed = 0.f, float vSpeed = 0.f,
bool fillHorizontal = true, bool fillVertical = true)
Source Code
Constructor of the class, it takes as parameters the texture, the position, the scene, the horizontal and vertical scrolling
speed and the two other parameters which are used to make horizontal and vertical filling.
2.2 step
void step(float const &DELTA_TIME)
Source Code
Allows to update the object.
Button
59
1. class Button
class Button;
Header : isEngine/system/entity/Button.h
Source Code
This Class allows to use a button in a scene.
2. Public methods
2.1 Button
First form
Button(sf::Texture &tex, float x, float y, std::string const &title, std::string const &name, bool center, is::GameDisplay
*scene)
Source Code
Constructor of the class, it takes as parameter the texture which will be used as the frame of the button, the position,
the title, object’s name, center the button in relation to the postion and the scene in which it will be used.
Second form
Button(sf::Texture &tex , sf::Font &font, float x, float y, std::string const &title, std::string const &name, bool center, int
textSize, is::GameDisplay *scene)
Source Code
Constructor of the class, it takes as parameter the texture which will be used as the frame of the button, the font, the
position, the title, object’s name, center the button in relation to the postion, text size and the scene in which it will be
used.
2.2 setTitle
virtual void setTitle(std::string const &title)
Source Code
Define the button title.
2.3 onClick
virtual void onClick() = 0;
Source Code
Allows to define the action that will be performed when we click on the button.
2.4 onMouseOver
virtual void(std::string const &title)
Source Code
Allows to define the action that will be performed when we hover over the button with the mouse (finger on Android).
2.5 event
virtual void(std::string const &title)
Source Code
60
Manage the event part of the button.
2.6 step
virtual void step(float const &DELTA_TIME)
Source Code
Allows to update the object.
2.7 draw
virtual void draw(is::Render &surface)
Source Code
Display the button with title.
2.8 getText
virtual sf::Text& getText()
Source Code
Return the text object of the button.
2.9 getIsInCollision
virtual bool getIsInCollision() const
Source Code
Return true when the mouse (finger on Android) collides with the button.
Admob
1. class AdmobManager
class AdmobManager;
Header: isEngine/system/android/AdmobManager.h
Source Code
Class that allows you to use the Admob SDK in the game. It offers functions to manage banner and reward video ads.
2. Public methods
2.1 AdmobManager
AdmobManager(sf::RenderWindow &window, ANativeActivity* activity, JNIEnv* env)
Source Code
Class constructor, it takes the window, Android activity and the JNI environement as parameters.
2.2 loadBannerAd
void loadBannerAd()
Source Code
61
Request for banner ad.
2.3 showBannerAd
void showBannerAd()
Source Code
Displays a banner ad provided the request has been successfully executed.
2.4 hideBannerAd
void hideBannerAd()
Source Code
Hide the banner ad.
2.5 loadRewardVideo
void loadRewardVideo()
Source Code
Request a reward video ad.
2.6 showRewardVideo
virtual int showRewardVideo()
Source Code
Allows you to launch a reward video ad.
Return 1 if the reward video is launched and 0 if there is an error (often occurs when the ad request did not work).
2.7 updateSFMLApp
auto updateSFMLApp(bool whiteColor)
Source Code
Updates the SFML application in the background when an ad is displayed. This avoids the main program crashing.
2.8 checkAdObjInit
void checkAdObjInit()
Source Code
Ensures the initialization of Admob components.
2.9 checkAdRewardObjReinitialize
void checkAdRewardObjReinitialize()
Source Code
Reset Admob components.
3. Other Functions of AdmobManager
3.1 ProcessEvents & WaitForFutureCompletion
62
static bool ProcessEvents(int msec)
static void WaitForFutureCompletion(firebase::FutureBase future)
Source Code
Ensures the proper functioning of tests on ad components.
3.2 checkAdState
static bool checkAdState(firebase::FutureBase future)
Source Code
Return true if the test on the ad component was successful, false if not.
Time
1. class GameTime
class GameTime;
Header: isEngine/system/function/GameTime.h
Source Code
This Class allows you to manipulate the game time (the stopwatch). Very useful for platform games like Super Mario
Bros or Sonic which uses a stopwatch in a level.
2. Public methods of GameTime
2.1 GameTime
First form
GameTime()
Source Code
Default constructor, initializes all counters (minute, second, millisecond) to zero (0).
Second form
GameTime(unsigned int ms)
Source Code
Constructor to initialize time with milliseconds which will be distributed later in minutes and seconds.
Third form
GameTime(unsigned int m, unsigned int s, unsigned int ms = 0)
Source Code
Constructor to initialize time with minutes, seconds and milliseconds.
2.2 step
void step(float const &DELTA_TIME, float const &VALUE_CONVERSION, float const &VALUE_TIME)
Source Code
63
Start the countdown timer so that it stops at zero (0).
2.3 addTimeValue
void addTimeValue(int m, int s = 0, int ms = 0)
Source Code
Add minutes, seconds and milliseconds to the current time.
2.4 setTimeValue
void setTimeValue(int m, int s = 0, int ms = 0)
Source Code
Set a new minute, second and millisecond for the current time.
2.5 setMSecond
void setMSecond(int ms)
Source Code
Set milliseconds which will be distributed in minutes and seconds.
2.6 getTimeString
const std::string getTimeString() const noexcept
Source Code
Return current time as a string (example 00: 00.00).
2.7 getTimeValue
unsigned int getTimeValue() const
Source Code
Return time in milliseconds.
2.8 getMinute
unsigned int getMinute() const
Source Code
Return the minute.
2.9 getSecond
unsigned int getSecond() const
Source Code
Return the second.
2.10 getMSecond
unsigned int getMSecond() const
Source Code
64
Return the millisecond.
2.11 compareTime
bool compareTime(unsigned int m, unsigned int s = 0, unsigned int ms = 0) const
Source Code
Compare the entered time and the time of the object.
Return true if the time entered is greater than the time of the object false if not.
2.12 operator=
GameTime& operator=(GameTime const &t)
Source Code
Equality operator to compare two objects.
2.13 operator<<
friend std::ostream& operator<<(std::ostream &flux, GameTime const &t)
Source Code
Operator to display the time with the std::cout.
3. Other functions of GameTime
bool operator==(GameTime const &t1, GameTime const &t2)
bool operator>(GameTime const &t1, GameTime const &t2)
bool operator<(GameTime const &t1, GameTime const &t2)
Source Code
These Operators allow you to make comparisons with objects.
Game control
class GameKeyData
Header: isEngine/system/function/GameKeyData.h
Source Code
Class that allows to manage the controls of the game. It supports the keyboard and the mouse on PC and becomes a
Virtual Game Pad on Android.
1. Elements of GameKeyData
2.1 enum VirtualKeyIndex
enum VirtualKeyIndex;
Enumerator
V_KEY_LEFT
Represents the LEFT key
V_KEY_RIGHT
Represents the RIGHT key
V_KEY_UP
Represents the UP key
65
V_KEY_DOWN
Represents the DOWN key
V_KEY_A
Represents the A key
V_KEY_B
Represents the B key
V_KEY_NONE
No key
Source Code
Represents game controls key.
2.2 GameKeyData
GameKeyData(is::GameDisplay *scene)
Source Code
Constructor who takes the scene as a parameter.
2.3 loadResources
void loadResources(sf::Texture &tex)
Source Code
Allows to load the texture which will be used to create the keys of the Virtual Game Pad.
2.4 step
void step(float const &DELTA_TIME)
Source Code
Updates the position of the Virtual Game Pad on the screen and also detects the use of commands.
2.5 draw
void draw(is::Render &surface)
Source Code
Displays the Virtual Game Pad.
2.6 m_keyPausePressed
bool m_keyPausePressed
Source Code
Determines if the pause key is pressed.
2.7 m_keyLeftPressed
bool m_keyLeftPressed
Source Code
Stores the state of the LEFT key.
2.8 m_keyRightPressed
bool m_keyRightPressed
Source Code
66
Stores the state of the RIGHT key.
2.9 m_keyUpPressed
bool m_keyUpPressed
Source Code
Stores the state of the UP key.
2.10 m_keyDownPressed
bool m_keyDownPressed
Source Code
Stores the state of the DOWN key.
2.11 m_keyAPressed
bool m_keyAPressed
Source Code
Stores the state of the A key.
2.12 m_keyBPressed
bool m_keyBPressed
Source Code
Stores the state of the B key.
2.13 m_keyAUsed
bool m_keyAUsed
Source Code
Stores the state of the A key when it is used.
2.14 m_keyBUsed
bool m_keyBUsed
Source Code
Stores the state of the B key when it is used.
2.15 m_keyLeftUsed
bool m_keyLeftUsed
Source Code
Stores the state of the LEFT key when it is used.
2.16 m_keyRightUsed
bool m_keyRightUsed
Source Code
67
Stores the state of the RIGHT key when it is used.
2.17 m_keyUpUsed
bool m_keyUpUsed
Source Code
Stores the state of the UP key when it is used.
2.18 m_keyDownUsed
bool m_keyDownUsed
Source Code
Stores the state of the DOWN key when it is used.
2.19 m_disableAllKey
bool m_disableAllKey
Source Code
Disables all game controls.
2.20 m_hideGamePad
bool m_hideGamePad
Source Code
Allows to hide the Virtual Game Pad on Android.
2.21 m_keyboardA
sf::Keyboard::Key m_keyboardA
Source Code
Represents the keyboard key that serves as the A key.
2.22 m_keyboardB
sf::Keyboard::Key m_keyboardB
Source Code
Represents the keyboard key that serves as the B key.
2.23 m_keyboardLeft
sf::Keyboard::Key m_keyboardLeft
Source Code
Represents the keyboard key that serves as the LEFT key.
2.24 m_keyboardRight
sf::Keyboard::Key m_keyboardRight
Source Code
68
Represents the keyboard key that serves as the RIGHT key.
2.25 m_keyboardUp
sf::Keyboard::Key m_keyboardUp
Source Code
Represents the keyboard key that serves as the UP key.
2.26 m_keyboardDown
sf::Keyboard::Key m_keyboardDown
Source Code
Represents the keyboard key that serves as the DOWN key.
2.27 m_moveKeyPressed
VirtualKeyIndex m_moveKeyPressed
Source Code
Used to find out whether the virtual directional keys are pressed.
2.28 m_actionKeyPressed
VirtualKeyIndex m_actionKeyPressed
Source Code
Used to find out whether the virtual keys A, B are pressed.
2.29 keyLeftPressed
bool keyLeftPressed()
Source Code
Return true if the LEFT directional key is pressed, false if not.
2.30 keyRightPressed
bool keyRightPressed()
Source Code
Return true if the RIGHT directional key is pressed, false if not.
2.31 keyUpPressed
bool keyUpPressed()
Source Code
Return true if the UP directional key is pressed, false if not.
2.32 keyDownPressed
bool keyDownPressed()
Source Code
69
Return true if the DOWN directional key is pressed, false if not.
2.33 keyAPressed
bool keyAPressed()
Source Code
Return true if the key A is pressed, false if not.
2.34 keyBPressed
bool keyBPressed()
Source Code
Return true if the key B is pressed, false if not.
2.35 virtualKeyPressed
bool virtualKeyPressed(VirtualKeyIndex virtualKeyIndex)
Source Code
Return true if the corresponding virtual key is pressed, false if not.
2. Other functions of GameKeyData
These functions are found in GameKeyName.h.
Header : isEngine/system/function/GameKeyName.h
First form
inline const char *getKeyName(const sf::Keyboard::Key key)
Source Code
Return the name of the keyboard key as a string.
Second form
inline std::wstring getKeyWName(const sf::Keyboard::Key key)
Source Code
Return the name of the keyboard key as a std::wstring.
Game Slider
1. class Game Slider
class TransitionEffect;
Header : isEngine/system/graphic/GameSlider.h
Source Code
Class that allows you to slide with your finger or mouse to navigate the menu.
70
2. Publics elements of Game Slider
2.1 Slider Direction
enum SlideDirection;
SlideDirection
SLIDE_NONE
Represents no slide
SLIDE_UP
Represents slide up
SLIDE_DOWN
Represents slide down
SLIDE_RIGHT
Represents slide right
SLIDE_LEFT
Represents slide left
Source Code
Represent the type of slide made by the user.
2.2 GameSlider
GameSlider(is::GameDisplay *scene)
Source Code
Constructor which takes as parameter the scene in which the slide function will be used.
2.3 step
void step(float const &DELTA_TIME)
Source Code
Allows to update object.
2.4 getSliderDirection
SlideDirection getSlideDirection() const
Source Code
Return the type of slide performed by the user (Supports case where user did not slip).
Game System
1. class GameSystem
class GameSystem;
Header : isEngine/system/function/GameSystem.h
Source Code
Base class which ensures the sharing of game information between the different components of the game engine. It
contains the global variables and functions which ensure the proper functioning of the engine.
2. Elements of GameSystem
2.1 enum ValidationButton
enum ValidationButton;
71
Enemerator
MOUSE
Represent the validation button of the mouse (if it is used, it becomes a touch action on
Android)
KEYBOARD
Represent the validation key on the keyboard
ALL_BUTTONS
Represent the validation button of the mouse and the keyboard (if it is used, it becomes a
touch action on Android)
Source Code
Represents the validation key on PC, It lets you know the button that will be used during a validation test.
2.2 GameSystem
GameSystem()
Source Code
Default constructor.
2.3 isPressed
bool isPressed(
#if defined(__ANDROID__)
int finger = 0
#else
ValidationButton validationButton = ALL_BUTTONS
#endif
) const
Source Code
Windows, Linux:
Checks if the validation key is pressed.
The validation key is defined in GameConfig.h (See here: 3.1).
Android :
Check if the screen is touched by the user.
Parameter :
finger finger index (on Android).
validationButton Represents the validation button to be used to perform the test.
Example:
Check if the validation key of the keyboard is pressed, by default this key is ENTER.
if (m_gameSystem.isPressed(is::GameSystem::ValidationButton::KEYBOARD))
{
// do something
}
Check if the validation button of the mouse is pressed, by default this button is LEFT.
72
if (m_gameSystem.isPressed(is::GameSystem::ValidationButton::MOUSE)
{
// do something
}
2.4 keyIsPressed
First form
bool keyIsPressed(sf::Keyboard::Key key) const
Source Code
Check if the keyboard key is pressed.
Return true if the key is pressed, false if not.
Second form
bool keyIsPressed(sf::Mouse::Button button) const
Source Code
Check if the mouse button is pressed.
Return true if the button is pressed, false if not.
2.5 fileExist
bool fileExist(std::string const &fileName) const
Source Code
Return true if the file exists, false if not.
2.6 playSound
void playSound(sf::Sound &obj)
Source Code
Allows to play a sound if the option is activated.
2.7 playMusic
void playSound(sf::Music &obj)
Source Code
Allows to play a music if the option is activated.
2.8 stopSound
void stopMusic(sf::Sound &obj)
Source Code
Allows to stop a sound.
2.9 stopMusic
void stopSound(sf::Music &obj)
73
Source Code
Allows to stop a music.
2.10 useVibrate
void useVibrate(short ms)
Source Code
Allows to use the vibrator if this option is activated (only for Android).
Parameter ms represents the duration of the vibrator in milliseconds.
2.11 saveConfig
void saveConfig(std::string const &fileName)
Source Code
Save game configuration data.
2.12 loadConfig
void loadConfig(std::string const &fileName)
Source Code
Load game configuration data.
2.13 savePadConfig
void savePadConfig(std::string const &fileName)
Source Code
Save the configuration data of the Virtual Game Pad.
2.14 loadPadConfig
void loadPadConfig(std::string const &fileName)
Source Code
Load the configuration data of the Virtual Game Pad.
2.15 m_disableKey
bool m_disableKey
Source Code
If it is true all the engine functions that manage the inputs (keyboard, mouse, touch) are disabled.
2.16 m_enableSound
bool m_enableSound
Source Code
Used to find out if the sound is activated.
2.17 m_enableMusic
74
bool m_enableMusic
Source Code
Used to find out if the music is activated.
2.18 m_enableVibrate
bool m_enableVibrate
Source Code
Used to find out if the vibrator is activated (only for Android).
2.19 m_keyIsPressed
bool m_keyIsPressed
Source Code
Used to find out if a key / button has been pressed.
2.20 m_firstLaunch
bool m_firstLaunch
Source Code
Check if the game has been launched at least once.
2.21 m_validationMouseKey
sf::Mouse::Button m_validationMouseKey
Source Code
Represent the variable that stores the validation button of the mouse.
2.22 m_validationKeyboardKey
sf::Keyboard::Key m_validationKeyboardKey
Source Code
Represents the variable that stores the keyboard validation key.
2.23 m_gameLanguage
int m_gameLanguage
Source Code
Represents the index of the chosen language.
2.24 m_padAlpha
int m_padAlpha
Source Code
Allows to modify the transparency of the Virtual Game Pad.
75
Game System Extended
1. class GameSystemExtended
class GameSystemExtended;
Header : app_src/gamesystem_ext/GameSystemExtended.h
Source Code
Class derived from GameSystem (click here for more information: 1), it performs the same role as its parent. Its
particularity is that it contains new elements which will be used to manage the game play and to manipulate the
different game scenes.
2. Elements of GameSystemExtended
2.1 GameSystemExtended
GameSystemExtended()
Source Code
Default constructor.
2.2 initSystemData
void initSystemData()
Source Code
Initializes the data linked to the game engine.
2.3 initProgress
void initProgress()
Source Code
Initialize game progress data.
2.4 initData
void initData(bool clearCurrentLevel = true)
Source Code
Initializes the game play data (score, life, etc.).
2.5 saveData
void saveData(std::string const &fileName)
Source Code
Save game data.
2.6 loadData
void loadData(std::string const &fileName)
Source Code
Load game data.
76
2.7 m_launchOption
DisplayOption m_launchOption
Source Code
Determine the action (click here to see the actions: 1) that will be performed on the different scenes of the game.
2.8 game play variables
int m_gameProgression
int m_levelNumber
int m_currentLevel
int m_currentLives
int m_currentBonus
int m_currentScore
int m_levelTime
Source Code
Global game variables.
Game Function
Header : isEngine/system/function/GameFunction.h
These functions allow you to do conversions on strings, manipulate time, manipulate SFML objects, display special
texts, use certain Android functions, perform geometric calculations, perform tests on variables, use functions to
manipulate random values, etc.
1. General Function
1.1 VALUE_CONVERSION
static float const VALUE_CONVERSION(65.f);
Source Code
Acts on the timing of counters.
Example:
This creates a counter in milliseconds when we put it in the update loop
// msCpt is an integer variable
msCpt += (is::VALUE_CONVERSION * 1.538f) * DELTA_TIME; // DELTA_TIME is the execution time returned by the
machine
1.2 SECOND
static float const SECOND(59.f);
Source Code
Represent a second.
1.3 WITH
#define WITH(_SIZE)
77
Source Code
Allows to browse a vector array. _I is the counter.
Example:
WITH(vectoreArray.size())
{
vectoreArray[_I]->function(…);
}
1.4 closeApplication
void closeApplication()
Source Code
Allows to close the application.
1.5 w_chart_tToStr
std::string w_chart_tToStr(wchar_t const *str)
Source Code
Convert w_chart_t to std::string.
1.6 strToWStr
std::wstring strToWStr(const std::string &str)
Source Code
Convert std::string to std::wstring.
1.7 numToStr
template <class T>
std::string numToStr(T val)
Source Code
Convert numeric to std::string.
1.8 strToNum
template <typename T>
T strToNum(const std::string &str)
Source Code
Convert std::string to numeric.
1.9 numToWStr
template <class T>
std::wstring numToWStr(T val)
Source Code
78
Convert numeric to std::wstring.
1.10 writeZero
template <class T>
std::string writeZero(T val, int zeroNumber = 1)
Source Code
Draw zeros in front of a number.
Parameter zeroNumber represents the number of zero to display.
Example:
int var(7);
std::cout << is::writeZero(var, 2) << std::endl; // its display in the console “007”
1.11 getMSecond
int getMSecond(float const &DELTA_TIME)
Source Code
Return execution time in milliseconds.
1.12 makeTime
std::tm makeTime(int year, int month, int day)
Source Code
Return a tm structure representing this date.
1.13 showLog
void showLog(const std::string& str , bool stopApplication = false)
Source Code
Displays messages in the console. If stopApplication is true it stops the application.
1.14 arraySize
template <size_t SIZE, class T>
inline size_t arraySize(T (&arr)[SIZE])
Source Code
Return the size of an array.
1.15 choose
template <typename T>
T choose(unsigned short valNumber, T x1, T x2, T x3 = 0, T x4 = 0, T x5 = 0, T x6 = 0, T x7 = 0, T x8 = 0, T x9 = 0)
Source Code
79
Selects a value randomly.
Parameter valNumber the number of values to test.
Example:
std::cout << is:: choose(3, 7, 12, 4) << std::endl; // its display in the console randomly 7 or 12 or 4
1.16 random
inline int random(unsigned int limit)
Source Code
Return a randam value based on the limit.
1.17 setVarLimit
template <typename T>
void setVarLimit(T &var, T valMin, T valMax)
Source Code
Allows to frame a value.
1.18 isIn
bool isIn(unsigned short valNumber, int const var, int x1, int x2, int x3 = 0, int x4 = 0, int x5 = 0, int x6 = 0, int x7 = 0, int
x8 = 0, int x9 = 0)
Source Code
Check if the value of a variable is in a value set.
Example:
int year(2020);
if (is::isIn(3, year, 2020, 2012, 2000)) // this condition will be true because the value of year is found in the function
{
// do something
}
1.19 isBetween
bool isBetween(float a, float b, float c)
Source Code
Check if a value is in an interval.
1.20 isCrossing
bool isCrossing(float l1, float r1, float l2, float r2)
Source Code
Checks if the point intersects another.
1.21 side
80
int side(Point m, Point a,Point b)
Source Code
Return -1 to the left, 1 to the right, 0 if a b c are aligned.
1.22 sign
int sign(float x)
Source Code
Return the sign of value.
1.23 pointDirection
template <typename T>
T pointDirection(float x1, float y1, float x2, float y2)
Source Code
Determine the angle between two points.
1.24 pointDistance
float pointDistance(float x1, float y1, float x2, float y2)
Source Code
Determine the distance between two points.
1.25 radToDeg
float radToDeg(float x)
Source Code
Convert radiant to degree.
1.26 degToRad
float degToRad(float x)
Source Code
Convert degree to radian.
1.27 lengthDirX
float lengthDirX(float dir, float angle)
Source Code
Return the component of x.
1.28 lengthDirY
float lengthDirY(float dir, float angle)
Source Code
Return the component of y.
81
1.29 increaseVar
template <typename T>
void increaseVar(const float &DELTA_TIME, T &var, T increaseValue, T varFinal, T varMax)
Source Code
Increment a variable with execution time.
Example:
int var(0);
is::increaseVar(DELTA_TIME, var, 1, 15, 10)); // the variable “varwill increment with the value 1. If it is
// greater than 10 it becomes 15 and the increment stops
1.30 decreaseVar
template <typename T>
void decreaseVar(const float &DELTA_TIME, T &var, T decreaseValue, T varFinal = 0, T varMin = 0)
Source Code
Decrement a variable with execution time.
Example:
int var(40);
is::decreaseVar(DELTA_TIME, var, 1, 20, 25)); // the variable “varwill decrement with the value 1. If it is
// less than 25 it becomes 20 and the decrement stops
1.31 collisionTest
bool collisionTest(Rectangle const &a, Rectangle const &b)
bool collisionTest(Circle const &a, Circle const &b)
bool collisionTest(Circle const &circle, Rectangle const &rec)
bool collisionTest(Rectangle const &rec, Circle const &circle)
Source Code
Test the collision between the Rectangle and Circle collision mask.
2. Function on objects SFML
2.1 setVector2
template <class T1, typename T2>
void setVector2(T1 &v, T2 x, T2 y)
Source Code
Define the x and y value of a Vector2 (Vector2f, Vector2i, …) type class.
2.2 getSFMLObjAngle
template <class T>
float getSFMLObjAngle(T obj)
82
Source Code
Return the angle of the object.
2.3 getSFMLObjXScale
template <class T>
float getSFMLObjXScale(T obj)
Source Code
Return the x-scale of the object.
2.4 getSFMLObjYScale
template <class T>
float getSFMLObjYScale(T obj)
Source Code
Return the y-scale of the object.
2.5 getSFMLObjWidth
template <class T>
float getSFMLObjWidth(T obj)
Source Code
Return the width of the object.
2.6 getSFMLObjHeight
template <class T>
float getSFMLObjHeight(T obj)
Source Code
Return the height of the object.
2.7 getSFMLTextureWidth
int getSFMTextureWidth(sf::Texture const &obj)
Source Code
Return the width of the Texture.
2.8 getSFMLTextureHeight
int getSFMLTextureHeight(sf::Texture const &obj)
Source Code
Return the height of the Texture.
2.9 getSFMLObjOriginX
template <class T>
83
float getSFMLObjOriginX(T obj)
Source Code
Return the origin x.
2.10 getSFMLObjOriginY
template <class T>
float getSFMLObjOriginY(T obj)
Source Code
Return the origin y.
2.11 getSFMLObjX
First form
template <class T>
float getSFMLObjX(T obj)
Second form
template <class T>
float getSFMLObjX(T *obj)
Source Code
Return position x.
2.12 getSFMLObjY
First form
template <class T>
float getSFMLObjY(T obj)
Second form
template <class T>
float getSFMLObjY(T *obj)
Source Code
Return position y.
2.13 setSFMLObjAngle
template <class T>
void setSFMLObjAngle(T &obj, float angle)
Source Code
Set the angle.
2.14 setSFMLObjRotate
84
template <class T>
void setSFMLObjRotate(T &obj, float rotationSpeed)
Source Code
Set the rotation of the object.
2.15 setSFMLObjScaleX_Y
template <class T>
void setSFMLObjScaleX_Y(T &obj, float x, float y)
Source Code
Define the scale x and y.
2.16 setSFMLObjScale
template <class T>
void setSFMLObjScale(T &obj, float scale)
Source Code
Set the scale x and y with the same value.
2.17 setSFMLObjOrigin
template <class T>
void setSFMLObjOrigin(T &obj, float x, float y)
Source Code
Set the origin x and y.
2.18 setSFMLObjX
template <class T>
void setSFMLObjX(T &obj, float x)
Source Code
Defines the position x.
2.19 setSFMLObjY
template <class T>
void setSFMLObjY(T &obj, float y)
Source Code
Defines the position y.
2.20 centerSFMLObj
template <class T>
void centerSFMLObj(T &obj)
85
Source Code
Center the object in x and y.
2.21 centerSFMLObjX
template <class T>
void centerSFMLObjX(T &obj)
Source Code
Center the object in x.
2.22 centerSFMLObjY
template <class T>
void centerSFMLObjY(T &obj)
Source Code
Center the object in y.
2.23 setSFMLObjX_Y
First form
template <class T>
void setSFMLObjX_Y(T &obj, sf::Vector2f position)
Second form
template <class T>
void setSFMLObjX_Y(T &obj, float x, float y)
Source Code
Defines the position x and y.
2.24 moveSFMLObjX
template <class T>
void moveSFMLObjY(T &obj, float speed)
Source Code
Moves the SFML object on the x-axis.
2.25 moveSFMLObjY
template <class T>
void moveSFMLObjY(T &obj, float speed)
Source Code
Moves the SFML object on the y-axis.
2.26 setSFMLObjSize
86
First form
template <class T>
void setSFMLObjSize(T &obj, float x, float y)
Second form
template <class T>
void setSFMLObjSize(T &obj, sf::Vector2f v)
Source Code
Set the size of the object.
2.27 setSFMLObjAlpha
First form
template <class T>
void setSFMLObjAlpha(T &obj, unsigned int alpha)
Second form
template <class T>
void setSFMLObjAlpha(T &obj, unsigned int alpha, int r, int g, int b)
Third form
template <class T>
void setSFMLObjAlpha(T &obj, unsigned int alpha, sf::Uint8 rgb)
Source Code
Set transparency. Can generate WARNINGS if used on texts and geometric shapes!
2.28 setSFMLObjAlpha2
template <class T>
void setSFMLObjAlpha2(T &obj, unsigned int alpha)
Source Code
Defines transparency for text, rectangles, etc. Does not work for sprites!
2.29 setSFMLObjColor
template <class T>
void setSFMLObjColor(T &obj, sf::Color color)
Source Code
Set the color of the object (Sprite).
2.30 setSFMLObjFillColor
template <class T>
87
void setSFMLObjFillColor(T &obj, sf::Color color)
Source Code
Defines the color of the object (Text, Rectangle, etc.).
2.31 scaleAnimation
template <class T>
void scaleAnimation(float const &DELTA_TIME, float &var, T &obj, short varSign = 1, float scaleSize = 1.f)
Source Code
Allows you to make a stretch animation on an SFML object.
2.32 setFrame
void setFrame(sf::Sprite &sprite, float frame, int subFrame, int frameSize, int recWidth, int recHeight)
void setFrame(sf::Sprite &sprite, float frame, int subFrame, int frameSize)
Source Code
Defines the animation of a sprite (click here Error! Reference source not found. to see how it is used).
2.33 setSFMLObjOutlineColor
First form
template <class T>
void setSFMLObjOutlineColor(T &obj, sf::Color color)
Source Code
Set the outline color.
Second form
template <class T>
void setSFMLObjOutlineColor(T &obj, float thickness, sf::Color color)
Source Code
Set the outline color and its size.
2.34 setSFMLObjTexRec
template <class T>
void setSFMLObjTexRec(T &obj, int x, int y, int w, int h)
Source Code
Set the intRect.
2.35 setSFMLObjProperties
void setSFMLObjProperties(sf::Sprite &obj, float x, float y, float angle = 0.f, int alpha = 255, float xScale = 1.f, float yScale
= 1.f)
88
void setSFMLObjProperties(sf::Text &obj, float x, float y, float angle = 0.f, int alpha = 255, float xScale = 1.f, float yScale =
1.f)
void setSFMLObjProperties(sf::RectangleShape &obj, float x, float y, float angle = 0.f, int alpha = 255, float xScale = 1.f,
float yScale = 1.f)
void setSFMLObjProperties(sf::CircleShape &obj, float x, float y, float angle = 0.f, int alpha = 255, float xScale = 1.f, float
yScale = 1.f)
Source Code
Defines the various properties of an SFML object.
2.36 loadSFMLTexture
void loadSFMLTexture(sf::Texture &obj, const std::string& filePath)
Source Code
Allows to load Texture.
2.37 loadSFMLFont
void loadSFMLFont(sf::Font &obj, const std::string& filePath)
Source Code
Allows to load Font.
2.38 loadSFMLSoundBuffer
void loadSFMLSoundBuffer(sf::SoundBuffer &obj, const std::string& filePath)
void loadSFMLSoundBuffer(sf::SoundBuffer &sb, sf::Sound &snd, const std::string& filePath)
Source Code
First : Allows to load a resource for an SFML object (Texture, Sound Buffer, etc.).
Second : Allows to load a resource file for a Sound Buffer and associate it with a sound.
2.39 loadSFMLMusic
void loadSFMLMusic(sf::Music &obj, const std::string& filePath)
Source Code
Allows to load Music.
2.40 checkSFMLSndState
enum SFMLSndStatus
{
Playing,
Stopped,
Paused
};
template <class T>
bool checkSFMLSndState(T &obj, SFMLSndStatus state)
bool checkSFMLSndState(T *obj, SFMLSndStatus state)
89
Source Code
Return the state of the sound.
2.41 playSFMLsnd
template <class T>
void playSFMLSnd(T &obj)
void playSFMLSnd(T *obj)
Source Code
Allows to play sound / music.
2.42 stopSFMLsnd
template <class T>
void stopSFMLSnd(T &obj)
void stopSFMLSnd(T *obj)
Source Code
Allows to stop sound / music.
2.43 pauseSFMLsnd
template <class T>
void pauseSFMLSnd(T &obj)
void pauseSFMLSnd(T *obj)
Source Code
Allows to pause sound / music.
2.44 loopSFMLsnd
template <class T>
void loopSFMLSnd(T &obj)
void loopSFMLSnd(T *obj)
Source Code
Allows to loop sound / music.
2.45 collisionTestSFML
template <class A, class B>
bool collisionTestSFML(A const &objA, B const &objB)
Source Code
Test the collision between two (2) SFML objects.
2.46 createRectangle
90
void createRectangle(sf::RectangleShape &rec, sf::Vector2f recSize, sf::Color color, float x = 0.f, float y = 0.f, bool center =
true)
Source Code
Create a rectangle with various parameters.
2.47 textStyleConfig
void textStyleConfig(sf::Text &txt, bool underLined, bool boldText, bool italicText)
Source Code
Defines the style of a text. Unsupported on the Web!
2.48 createWText
void createWText(sf::Font const& fnt, sf::Text &txt, std::wstring const &text, float x, float y, sf::Color color, int txtSize =
DEFAULT_SFML_TEXT_SIZE)
Source Code
Create a text with a std::wstring.
2.49 createText
First form
void createText(sf::Font const& fnt, sf::Text &txt, std::string const &text, float x, float y, int txtSize =
DEFAULT_SFML_TEXT_SIZE)
Second form
void createText(sf::Font const& fnt, sf::Text &txt, std::string const &text, float x, float y, bool centerText, int txtSize =
DEFAULT_SFML_TEXT_SIZE)
Third form
void createText(sf::Font const& fnt, sf::Text &txt, std::string const &text, float x, float y, sf::Color color, int txtSize =
DEFAULT_SFML_TEXT_SIZE)
Fourth form
void createText(sf::Font const& fnt, sf::Text &txt, std::string const &text, float x, float y, sf::Color color, bool centerText,
int txtSize = DEFAULT_SFML_TEXT_SIZE)
Source Code
These functions allow to create text with various parameters.
2.50 createSprite
First form
void createSprite(sf::Texture &tex, sf::Sprite &spr, sf::Vector2f position, sf::Vector2f origin, bool smooth = true)
Second form
void createSprite(sf::Texture &tex, sf::Sprite &spr, sf::IntRect rec, sf::Vector2f position, sf::Vector2f origin, bool
repeatTexture = false, bool smooth = true)
Third form
91
void createSprite(sf::Texture &tex, sf::Sprite &spr, sf::IntRect rec, sf::Vector2f position, sf::Vector2f origin, sf::Vector2f
scale, unsigned int alpha = 255, bool repeatTexture = false, bool smooth = true)
Source Code
These functions allow to create a sprite with various parameters.
2.51 getCursor
sf::Vector2f getCursor(sf::RenderWindow &window
#if defined(__ANDROID__)
, unsigned int finger = 0
#endif
)
Source Code
Return the position of the cursor (touch on Android). finger represents the finger.
2.52 mouseCollision
First form
template <class T>
bool mouseCollision(sf::RenderWindow &window, T const &obj
#if defined(__ANDROID__)
, unsigned int finger = 0
#endif
)
Source Code
Windows, Linux: Detects if the mouse cursor collides with an object in the window.
Android: Detects if the user touches an object in the window.
Parameter:
obj the object with which we want to test.
finger represents the finger.
Return true if there is a collision and false if not.
Example :
if (mouseCollision(window, sprite))
{
// do something
}
Second form
template <class T>
92
bool mouseCollision(sf::RenderWindow &window, T const &obj, sf::RectangleShape &cursor
#if defined(__ANDROID__)
, unsigned int finger = 0
#endif
)
Source Code
Windows, Linux: Detects if the mouse cursor collides with an object in the window.
Android: Detects if the user touches an object in the window.
Parameter:
obj the object with which we want to test.
cursor allows to recover the position of the collision point.
finger represents the finger.
Return true if there is a collision and false if not.
Example:
sf::ReactangleShape rec;
if (mouseCollision(window, sprite, rec))
{
float cursorXPosition = rec.getPosition.x();
float cursorYPosition = rec.getPosition.y();
}
3. Other functions
3.1 clear
template <class T2, class T2>
void clear(T &render, T2 color)
Source Code
Allows to clear render with color.
3.2 draw
template < class T2, class T2>
void draw(T1 &render, T2 &obj)
void draw(T1 &render, T2 *obj)
Source Code
Allows to draw object on render.
3.3 display
template <class T>
93
void display(T &render)
Source Code
Allows to display render.
3.4 setFPS
template <class T>
void setFPS(T &render, float fps)
Source Code
Allows to set frame per seconds.
3.5 vibrate
int vibrate(short duration)
Source Code
Launches the Android vibrator.
3.6 openURL
void openURL(const std::string& url)
Source Code
Open a URL in the browser (e.g www.website.com).
3.7 jstring2string
static std::string jstring2string(JNIEnv *env, jstring jStr)
Source Code
Convert jstring to std::string.
3.8 getDeviceId
static std::string getDeviceId(JNIEnv *env, ANativeActivity *activity)
Source Code
Return Android device id.
External library
1. Tiny File Dialogs (only for Windows and Linux)
2.1 class TinyDialogBox
class TinyDialogBox;
Header : isEngine/ext_lib/TinyFileDialogs/TinyDialogsBox.h
Source Code
94
A class that allows you to use the Tinyfiledialogs library in the simplest way. It allows you to use the dialog boxes of the
operating system (Windows and Linux).
2.2 tinyString
#if !defined(SFML_SYSTEM_LINUX)
typedef wchar_t const* tinyString;
#else
typedef char const* tinyString;
#endif
Source Code
Custom type which allows to manipulate the data of tinyFileDialogs. When using tinyFileDialogs different data
depending on the operating system. On windows the strings become wchar_t const* and on Linux char const*, which
implies the use of two (2) different types having the same purpose for the same program. The tinyString type
overcomes this problem by automatically determining the type that corresponds to the target operating system.
2.3 TINY_FILE_DIALOGBOX_PATH
static tinyString TINY_FILE_DIALOGBOX_PATH;
Source Code
Stores file path of dialog box.
2.4 enum FileDialogType
enum FileDialogType;
Enumerator
SAVE_FILE
Save file
LOAD_FILE
Load file
Source Code
Represents the type of dialog box to display.
2.5 enum DialogType
enum DialogType;
Enumerator
OK
Message with button OK
OKCANCEL
Message with button OK et CANCEL
YESNO
Message with button YES et NO
Source Code
Represents the buttons that will be displayed on the dialog box.
2.6 enum IconType
enum IconType;
Enumerator
95
INFO
Dialog box with an INFO icon
WARNING
Dialog box with an WARNING icon
ERROR_ICO
Dialog box with an ERROR icon
QUESTION
Dialog box with an QUESTION icon
Source Code
Represents the icon that will be displayed on the dialog box.
2.7 enumDialogTypeToStr / enumIconTypeToStr
static tinyString const enumDialogTypeToStr(DialogType val)
static tinyString const enumIconTypeToStr(IconType val)
Source Code
These functions convert enum to string which will be used later in the library functions.
2.8 showDialogBox
static int showDialogBox(const std::string& title,
const std::string& msg,
DialogType dialogType,
IconType iconType
)
Source Code
Displays a message dialog box.
Return 1 when the user clicks on the OK button and 0 when he clicks on CANCEL or NO.
2.9 showFileDialogBox
static std::string showFileDialogBox(FileDialogType type,
const std::string& title,
tinyString filterPatterns[],
const std::string& fileName = "file",
const std::string& msgError = "Unable to access file!",
const std::string& errTitle = "Error"
)
Source Code
Displays a file dialog box.
Return file path if the function was successful and "" (empty string) if not.
2.10 showFolderDialogBox
static std::string showFolderDialogBox(const std::string& title,
96
const std::string& defaultPath,
#if !defined(SFML_SYSTEM_LINUX)
= L"C:\\",
#else
= "/home/",
#endif
const std::string& msgError = "Unable to access folder!",
const std::string& errTitle = "Error"
)
Source Code
Displays a folder selection dialog box.
Return folder path if function was successful and "" (empty string) if not.
2. Box 2D
Box 2D is a physical engine integrated into the game engine. To use it in a scene you must include it this way:
#include "../../../isEngine/ext_lib/Box2D/Box2D.h"
3. TMXLite
TMXLite is a library that allows to use Tiled editor with the game engine. To use it in a scene you must include it this
way:
#include "../../../isEngine/ext_lib/TMXLite/Map.hpp"
Game Engine
1. class GameEngine
class GameEngine;
Header : isEngine/core/GameEngine.h
Source Code
This Class ensures the interconnection of the different components of the engine and launches the rendering loop in
which the game will take place.
2. Methods of GameEngine
2.1 GameEngine
GameEngine()
Source Code
Default constructor.
2.2 initEngine
97
bool initEngine()
Source Code
Initializes the game engine.
2.3 play
bool play()
Source Code
Game engine main render loop.
2.4 basicSFMLmain
bool basicSFMLmain()
Source Code
Classic SFML window rendering loop.
2.5 getRenderWindow
sf::RenderWindow& getRenderWindow()
Source Code
Return SFML window.
Game setup
namespace GameConfig;
Header : app_src/config/GameConfig.h
Allows you to define parameters to preconfigure these parts of the game: The size of the window and the view, The
keyboard and mouse keys to use to control the game, the game information (name, author, version), path resource files
(sound, image, backup, etc.) and Admob information.
1. enum DisplayOption
enum DisplayOption;
Enumerator
RESUME_GAME
When player close pause menu
GAME_OPTION_RESTART
Restart the scene with the restart option
QUIT_GAME
When player use quit option
INTRO
Access the Introduction scene
RESTART_LEVEL
Restart the scene when you lose
NEXT_LEVEL
Go to the next level
MAIN_MENU
Access the Main Menu scene
GAME_LEVEL
Access the Game Level scene
GAME_OVER
Access the Game Over scene
GAME_END_SCREEN
Go to the End of Game scene
Source Code
98
Allows to manipulate the different scenes and menu pause.
2. Window setting
2.1 WINDOW_WIDTH
static const unsigned int WINDOW_WIDTH
Source Code
Set window width.
2.2 WINDOW_HEIGHT
static const unsigned int WINDOW_HEIGHT
Source Code
Set window height.
2.3 VIEW_WIDTH
static const float VIEW_WIDTH
Source Code
Set view width.
2.4 VIEW_HEIGHT
static const float VIEW_HEIGHT
Source Code
Set view height.
2.5 FPS
static const float FPS
Source Code
Set the FPS (Frame Per Second) of the game.
2.6 WINDOW_SETTINGS
static const is::WindowStyle WINDOW_SETTINGS
Source Code
Set the window style.
3. Parameter of validation buttons
3.1 KEY_VALIDATION_MOUSE
static const sf::Mouse::Button KEY_VALIDATION_MOUSE
Source Code
Represents the button that validates the options with the mouse.
3.2 KEY_VALIDATION_KEYBOARD
static const sf::Keyboard::Key KEY_VALIDATION_KEYBOARD
99
Source Code
Represents the key that validates the options with the keyboard.
3.3 KEY_CANCEL
static const sf::Keyboard::Key KEY_CANCEL
Source Code
Represents the key that cancels options with the keyboard.
4. Keyboard key setting
4.1 KEY_A
static const sf::Keyboard::Key KEY_A
Source Code
Represents the key A.
4.2 KEY_B
static const sf::Keyboard::Key KEY_B
Source Code
Represents the key B.
4.3 KEY_LEFT
static const sf::Keyboard::Key KEY_LEFT
Source Code
Represents the key LEFT.
4.4 KEY_RIGHT
static const sf::Keyboard::Key KEY_RIGHT
Source Code
Represents the key RIGHT.
4.5 KEY_UP
static const sf::Keyboard::Key KEY_UP
Source Code
Represents the key UP.
4.6 KEY_DOWN
static const sf::Keyboard::Key KEY_DOWN
Source Code
Represents the key DOWN.
5. Default value for SFML components
5.1 DEFAULT_SFML_TEXT_SIZE
100
static const DEFAULT_SFML_TEXT_SIZE
Source Code
Set the default size of SFML text objects.
5.2 DEFAULT_SFML_TEXT_COLOR
static const sf::Color &DEFAULT_SFML_TEXT_COLOR
Source Code
Set the default color for SFML text objects.
5.3 DEFAULT_SFML_SELECTED_TEXT_COLOR
static const sf::Color &DEFAULT_SFML_SELECTED_TEXT_COLOR
Source Code
Set the default color of SFML text objects when they are selected.
5.4 DEFAULT_MSG_BOX_TEXT_COLOR
static const sf::Color &DEFAULT_MSG_BOX_TEXT_COLOR
Source Code
Define the default color of SFML text objects for the dialog box.
5.5 DEFAULT_MSG_BOX_SELECTED_TEXT_COLOR
static const sf::Color &DEFAULT_MSG_BOX_SELECTED_TEXT_COLOR
Source Code
Define the default color of SFML text objects for the dialog box when they are selected.
5.6 DEFAULT_RPG_DIALOG_TEXT_COLOR
static const sf::Color &DEFAULT_RPG_DIALOG_ TEXT_COLOR
Source Code
Set the default color of SFML text objects for the RPG dialog box.
5.7 DEFAULT_RPG_DIALOG_SELECTED_TEXT_COLOR
static const sf::Color &DEFAULT_RPG_DIALOG_SELECTED_TEXT_COLOR
Source Code
Set the default color of SFML text objects (button Skip) for the RPG dialog box.
5.8 DEFAULT_BUTTON_TEXT_COLOR
static const sf::Color & DEFAULT_BUTTON_TEXT_COLOR
Source Code
Set the default color of button text.
6. Game information
101
5.1 MAJOR
static const std::string MAJOR
Source Code
Set the major version.
5.2 MINOR
static const std::string MINOR
Source Code
Set the minor version.
5.3 getGameVersion
inline std::string getGameVersion()
Source Code
Return version of the game.
5.4 GAME_NAME
static std::wstring const GAME_NAME
Source Code
Set the name of the game.
5.5 GAME_AUTHOR
static std::wstring const GAME_AUTHOR
Source Code
Set the name of the author.
7. Admob setting
namespace AdmobConfig;
Allows you to define Admob information so that ads can be displayed in the game. This information is provided on the
Google Admob platform!
7.1 Ad Id
7.1.1 kAdMobAppID
static const char* kAdMobAppID
Source Code
Admob application code.
7.1.2 kBannerAdUnit
static const char* kBannerAdUnit
Source Code
Banner code.
102
7.1.3 kRewardedVideoAdUnit
static const char* kRewardedVideoAdUnit
Source Code
Reward video code.
7.2 Banner size
7.2.1 kBannerWidth
static const int kBannerWidth
Source Code
Set the width of the ad banner.
7.2.2 kBannerHeight
static const int kBannerHeight
Source Code
Set the height of the ad banner.
7.3 Target audience
7.3.1 kBirthdayDay
static const int kBirthdayDay
Source Code
Set users' birth day.
7.3.2 kBirthdayMonth
static const int kBirthdayMonth
Source Code
Set users' birth month.
7.3.3 kBirthdayYear
static const int kBirthdayYear
Source Code
Define users' year of birth.
7.3.4 kKeywords
static const char* kKeywords[]
Source Code
Keywords to use when requesting an ad.
8. Path of the resource files
8.1 ASSETS_DIR
static std::string const ASSETS_DIR
103
Source Code
Root of resource files.
8.2 GUI_DIR
static std::string const GUI_DIR
Source Code
Path of resource files that serve as a graphical interface.
8.3 FONT_DIR
static std::string const FONT_DIR
Source Code
Path of resource files that serve as font.
8.4 SPRITES_DIR
static std::string const SPRITES_DIR
Source Code
Path of resource files that serve as Sprite.
8.5 TILES_DIR
static std::string const TILES_DIR
Source Code
Path to resource files that serve as tiles and background.
8.6 SFX_DIR
static std::string const SFX_DIR
Source Code
Path of resource files that serve as SFX.
8.7 MUSIC_DIR
static std::string const MUSIC_DIR
Source Code
Path to resource files that serve as music.
8.8 TMX_RSC_DIR
static std::string const TMX_RSC_DIR
Source Code
Path of the TMX Loader and Lite library resource files.
9. Game package name (Android)
static std::string const PACKAGE_NAME
104
Source Code
Name of the game package. Represents the place where your data will be saved on Android.
You must apply this name for the applicationId in the build.gradle file
10. Backup file path
10.1 DATA_PARENT_DIR
static std::string const DATA_PARENT_DIR
Source Code
Root of game datas files.
10.2 GAME_DATA_FILE
static std::string const GAME_DATA_FILE
Source Code
Path to the game save file.
10.3 CONFIG_FILE
static std::string const CONFIG_FILE
Source Code
Path to the game configuration file.
10.4 GAME_PAD_FILE
static std::string const GAME_PAD_FILE
Source Code
Path for the configuration file of the Virtual Game Pad on Android.
Activity
1. class GameActivity
class GameActivity;
Header : app_src/activity/GameActivity.h
Source Code
Allows you to launch the different game scenes. Another special feature of this class is that it links the engine scenes.
2. Elements of GameActivity
2.1 GameActivity
GameActivity(GameSystemExtended &gameSysExt)
Source Code
Class constructor, it takes as parameter the game system manager (click here for more information: 1).
105
2.2 m_gameScene
std::shared_ptr<is::GameDisplay> m_gameScene;
Source Code
Instance of the scene that will be used.
2.3 onUpdate
virtual void onUpdate()
Source Code
Used to update scene information.
2.4 onDraw
virtual void onDraw()
Source Code
Displays the scene.
Game Level
1. Level
In is::Engine the game levels are integer arrays contained in header files (file.h). These levels are created thanks to
is::Level Editor (project link) which is delivered with the engine.
Header : app_src/levels/Level.h
2. Integration of a level
To integrate a level we include its header in the Level.h file in this way:
#include "../levels/level_1.h"
3. Elements to manage levels
3.1 namespace level
namespace level;
Source Code
Contains the elements which are used to manage the levels.
3.2 enum LevelId
enum LevelId
{
LEVEL_1,
LEVEL_2,
/* … */
, LEVEL_MAX // Allows to know the total number of integrated level
106
}
Source Code
Represents the index of each level. Each time a new level is integrated into the engine, you must declare its index.
3.3 getLevelMap
inline short const* getLevelMap(int CURRENT_LEVEL)
Source Code
Return the level array entered in the parameter.
Each time a new level is integrated, you must enter the instruction that will return this level in the function.
Example:
Integration in function:
// Returns the level array found in level_1.h
inline short const* getLevelMap(int CURRENT_LEVEL)
{
switch (CURRENT_LEVEL)
{
case LEVEL_1 : return LEVEL_1_MAP; break; // LEVEL_1_MAP is the name of the array found in level_1.h
// ...
Use in an external source file: (This is a simple example just to explain the principle to you. To go further,
please refer to the Engine Demo)
short *currentLevelArray = getLevelMap(LEVEL_1); // Return the array which is in level_1.h
Game language
1. Languages
Languages are represented in is::Engine by string arrays.
Header : app_src/language/GameLanguage.h
2. Elements to manage languages
2.1 namespace lang
namespace lang;
Source Code
Used to manage game languages.
2.2 enum GameLanguage
enum GameLanguage
{
107
ENGLISH, ///< Represents the English language
FRANCAIS, ///< Represents the French language
/* … */
}
Source Code
This enumeration allows to implement the index of each language in order to provide the used more easily during the
development.
Example:
Create a sentence:
static std::string hello_world[] = { "Hello World !", "Salut le monde !" }; // To put in GameLanguage.h
Use: (This is a simple example just to explain the principle to you. To go further, please refer to the Engine
Demo)
gameSystemExt.m_gameLanguage = is::lang::GameLanguage::ENGLISH; // Choice of English language
is::showLog(is::lang::hello_world[gameSystemExt.m_gameLanguage]); // we will have in the console: Hello World !
gameSystemExt.m_gameLanguage = is::lang::GameLanguage::FRANCAIS; // Choice of French language
is::showLog(is::lang::hello_world[gameSystemExt.m_gameLanguage]); // we will have in the console: Salut le monde
!"
Game Dialog Box
1. class GameDialog
class GameDialog;
Header : app_src/objects/widgets/GameDialog.h
Source Code
Class that allows you to display dialog boxes like in RPG games. It is closely related to the language part of the game
(click here for more information: 1). To be able to display a dialog you must define a string array representing this
dialog in GameLanguage.h
2. Elements of GameDialog
2.1 GameDialog
GameDialog(sf::Texture &tex, sf::Font &fnt, is::GameDisplay *scene)
Source Code
Constructor of the class, it takes as a parameter texture, font and the scene in which it is used.
2.2 enum DialogIndex
enum DialogIndex
{
108
DIALOG_NONE = -1,
DIALOG_PLAYER_MOVE, // Represents the dialog that talks about how to move the player
/* … */
};
Source Code
Represents the different dialogs that will be displayed in the game. The information that is defined inside is linked to
the language part of the game.
Each time an index is added we must declare its string array in GameLanguage.h.
Example:
DIALOG_PLAYER_MOVE dialog declaration in GameLanguage.h :
static std::wstring dialog_player_move[] = {L"Press LEFT or RIGHT to move.\n"
"Press A to Jump.",
L"Appuie sur GAUCHE ou DROITE pour te déplacer.\n"
"Appuie sur A pour sauter."};
2.3 linkArrayToEnum
void linkArrayToEnum()
Source Code
Connect the string array found in GameLanguage.h and the dialogue index.
Example:
Link an Index and its string array: (This is a simple example just to explain the principle to you. To go
further, please refer to the Engine Demo)
void linkArrayToEnum()
{
// …
switch (m_dialogIndex)
{
case DIALOG_PLAYER_MOVE: // dialogue index
m_msgIndexMax = is::arraySize(is::lang::dialog_player_move); // Determines the number of sentences
checkMsg(is::lang::dialog_player_move); // Define the dialogue thanks to its string array
break;
// …
2.4 step
void step(const float &DELTA_TIME)
109
Source Code
Updates the information in the dialog box.
2.5 setDialog
void setDialog(DialogIndex dialogIndex)
Source Code
Defines the dialog that will be launched.
2.6 setMouseInCollison
void setMouseInCollison(bool val)
Source Code
Force the collision of the mouse cursor or finger (on Android) with the dialog box.
2.7 draw
void draw(is::Render &surface)
Source Code
Displays the dialog box.
2.8 getDialogIndex
DialogIndex getDialogIndex() const
Source Code
Return the enumerator of the dialog that is displayed.
2.9 getMouseInCollison
bool getMouseInCollison() const
Source Code
Return true when the mouse cursor or the user's finger (on Android) touches the dialog box, false if not.
2.10 showDialog
bool showDialog() const
Source Code
Return true when the dialog is open and false if not.